Browse Source

Updated for 2010 URL of the WSDL contract. Various improvements.

- added vies.png: image of the UI
- added eu_flags.jpg: the photo used in the About box
- glade: added quit PDC handler
- code: updated WSDL URL
- code: new bracing style
- code: pre-launch requirements check
Frederic G. Marand 13 years ago
parent
commit
979e72c5ad
4 changed files with 287 additions and 149 deletions
  1. BIN
      eu_flags.jpg
  2. 195 74
      vies.glade
  3. 92 75
      vies.phpw
  4. BIN
      vies.png

BIN
eu_flags.jpg


+ 195 - 74
vies.glade

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.0.2 on Sun Apr 08 23:35:51 2007 by Marand@PC-OSI-->
+<!--Generated with glade3 3.0.2 on Mon Apr 09 18:38:56 2007 by Marand@PC-OSI-->
 <glade-interface>
 <glade-interface>
   <widget class="GtkWindow" id="w">
   <widget class="GtkWindow" id="w">
     <property name="title" translatable="yes">Check EU VAT ID using VIES</property>
     <property name="title" translatable="yes">Check EU VAT ID using VIES</property>
@@ -11,6 +11,85 @@
       <widget class="GtkVBox" id="vb">
       <widget class="GtkVBox" id="vb">
         <property name="visible">True</property>
         <property name="visible">True</property>
         <property name="spacing">1</property>
         <property name="spacing">1</property>
+        <child>
+          <widget class="GtkMenuBar" id="ab">
+            <property name="visible">True</property>
+            <child>
+              <widget class="GtkMenuItem" id="abc_file">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_File</property>
+                <property name="use_underline">True</property>
+                <child>
+                  <widget class="GtkMenu" id="menu1">
+                    <property name="visible">True</property>
+                    <child>
+                      <widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
+                        <property name="visible">True</property>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkMenuItem" id="pdc_save">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Save</property>
+                        <property name="use_underline">True</property>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkMenuItem" id="pdc_quit">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Quit</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_quit_action"/>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkMenuItem" id="abc_edit">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Edit</property>
+                <property name="use_underline">True</property>
+                <child>
+                  <widget class="GtkMenu" id="menu2">
+                    <property name="visible">True</property>
+                    <child>
+                      <widget class="GtkMenuItem" id="pdc_preferences">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">_Preferences</property>
+                        <property name="use_underline">True</property>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkMenuItem" id="abc_help">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Help</property>
+                <property name="use_underline">True</property>
+                <child>
+                  <widget class="GtkMenu" id="menu3">
+                    <property name="visible">True</property>
+                    <child>
+                      <widget class="GtkMenuItem" id="pdc_about">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">_About</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_pdc_about_activate"/>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+          </packing>
+        </child>
         <child>
         <child>
           <widget class="GtkHBox" id="hb">
           <widget class="GtkHBox" id="hb">
             <property name="visible">True</property>
             <property name="visible">True</property>
@@ -61,6 +140,7 @@ SK - Slovakia</property>
           <packing>
           <packing>
             <property name="expand">False</property>
             <property name="expand">False</property>
             <property name="fill">False</property>
             <property name="fill">False</property>
+            <property name="position">1</property>
           </packing>
           </packing>
         </child>
         </child>
         <child>
         <child>
@@ -75,7 +155,7 @@ SK - Slovakia</property>
             <property name="expand">False</property>
             <property name="expand">False</property>
             <property name="fill">False</property>
             <property name="fill">False</property>
             <property name="padding">2</property>
             <property name="padding">2</property>
-            <property name="position">1</property>
+            <property name="position">2</property>
           </packing>
           </packing>
         </child>
         </child>
         <child>
         <child>
@@ -92,11 +172,11 @@ SK - Slovakia</property>
                 <child>
                 <child>
                   <widget class="GtkTextView" id="tv">
                   <widget class="GtkTextView" id="tv">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="text" translatable="yes">This applet allows EU companies to check the validity of 
+                    <property name="text" translatable="yes">This applet allows EU companies to check the validity of
 EU VAT registrations according to the official EU VIES
 EU VAT registrations according to the official EU VIES
 (VAT Information Exchange System) service.
 (VAT Information Exchange System) service.
 
 
-More detail about the service is available at 
+More detail about the service is available at
 http://ec.europa.eu/taxation_customs/vies/en/vieshome.htm</property>
 http://ec.europa.eu/taxation_customs/vies/en/vieshome.htm</property>
                   </widget>
                   </widget>
                 </child>
                 </child>
@@ -120,91 +200,80 @@ http://ec.europa.eu/taxation_customs/vies/en/vieshome.htm</property>
                 <property name="column_spacing">2</property>
                 <property name="column_spacing">2</property>
                 <property name="row_spacing">2</property>
                 <property name="row_spacing">2</property>
                 <child>
                 <child>
-                  <widget class="GtkImage" id="imgValid">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="stock">gtk-dialog-question</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="lbAddress">
+                  <widget class="GtkLabel" id="lbCountryCode">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
                     <property name="xalign">1</property>
                     <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">Address</property>
+                    <property name="label" translatable="yes">Country Code</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="top_attach">5</property>
-                    <property name="bottom_attach">6</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbName">
+                  <widget class="GtkLabel" id="lbCountryCodeVal">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
+                    <property name="xalign">0</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">Name</property>
+                    <property name="label" translatable="yes">?</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbValid">
+                  <widget class="GtkLabel" id="lbRequestDateVal">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
+                    <property name="xalign">0</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">Valid ?</property>
+                    <property name="label" translatable="yes">?</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbRequestDate">
+                  <widget class="GtkLabel" id="lbVatNumberVal">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
+                    <property name="xalign">0</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">Request Date</property>
+                    <property name="label" translatable="yes">?</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbVatNumber">
+                  <widget class="GtkLabel" id="lbNameVal">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">1</property>
+                    <property name="xalign">0</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">VAT number</property>
+                    <property name="label" translatable="yes">---</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
@@ -228,81 +297,92 @@ http://ec.europa.eu/taxation_customs/vies/en/vieshome.htm</property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbNameVal">
+                  <widget class="GtkLabel" id="lbVatNumber">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">0</property>
+                    <property name="xalign">1</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">---</property>
+                    <property name="label" translatable="yes">VAT number</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">4</property>
-                    <property name="bottom_attach">5</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbVatNumberVal">
+                  <widget class="GtkLabel" id="lbRequestDate">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">0</property>
+                    <property name="xalign">1</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">?</property>
+                    <property name="label" translatable="yes">Request Date</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">1</property>
-                    <property name="bottom_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbRequestDateVal">
+                  <widget class="GtkLabel" id="lbValid">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">0</property>
+                    <property name="xalign">1</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">?</property>
+                    <property name="label" translatable="yes">Valid ?</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbCountryCodeVal">
+                  <widget class="GtkLabel" id="lbName">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
-                    <property name="xalign">0</property>
+                    <property name="xalign">1</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">?</property>
+                    <property name="label" translatable="yes">Name</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
                 <child>
                 <child>
-                  <widget class="GtkLabel" id="lbCountryCode">
+                  <widget class="GtkLabel" id="lbAddress">
                     <property name="visible">True</property>
                     <property name="visible">True</property>
                     <property name="xalign">1</property>
                     <property name="xalign">1</property>
+                    <property name="yalign">0</property>
                     <property name="xpad">5</property>
                     <property name="xpad">5</property>
-                    <property name="label" translatable="yes">Country Code</property>
+                    <property name="label" translatable="yes">Address</property>
                     <property name="single_line_mode">True</property>
                     <property name="single_line_mode">True</property>
                   </widget>
                   </widget>
                   <packing>
                   <packing>
+                    <property name="top_attach">5</property>
+                    <property name="bottom_attach">6</property>
                     <property name="x_options">GTK_FILL</property>
                     <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkImage" id="imgValid">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="stock">gtk-dialog-question</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
                     <property name="y_options"></property>
                     <property name="y_options"></property>
                   </packing>
                   </packing>
                 </child>
                 </child>
@@ -320,7 +400,7 @@ http://ec.europa.eu/taxation_customs/vies/en/vieshome.htm</property>
             </child>
             </child>
           </widget>
           </widget>
           <packing>
           <packing>
-            <property name="position">2</property>
+            <property name="position">3</property>
           </packing>
           </packing>
         </child>
         </child>
         <child>
         <child>
@@ -329,7 +409,48 @@ http://ec.europa.eu/taxation_customs/vies/en/vieshome.htm</property>
           </widget>
           </widget>
           <packing>
           <packing>
             <property name="expand">False</property>
             <property name="expand">False</property>
-            <property name="position">3</property>
+            <property name="position">4</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+  <widget class="GtkAboutDialog" id="dl_about">
+    <property name="border_width">5</property>
+    <property name="title">About VIES Client</property>
+    <property name="resizable">False</property>
+    <property name="version">$Id: vies.glade,v 1.2 2010-09-21 09:05:15 fgm Exp $</property>
+    <property name="copyright" translatable="yes">(c) 2007-2010 Frédéric G. MARAND</property>
+    <property name="comments" translatable="yes">A PHP-GTK client for the EU
+VAT Information Exchange System</property>
+    <property name="website">http://blog.riff.org/</property>
+    <property name="website_label" translatable="yes">Riff Blog</property>
+    <property name="license" translatable="yes">CeCILL 2.0</property>
+    <property name="authors">Frédéric G. MARAND</property>
+    <property name="documenters">Frédéric G. MARAND</property>
+    <property name="artists">Photo:
+http://www.flickr.com/photos/jamespaullong/132456441/
+Photo normally licensed under CC BY NC ND
+Specific ND-exemption for this application
+granted by the photo author.</property>
+    <property name="logo">eu_flags.jpg</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dl_vb">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
+        <property name="spacing">2</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
           </packing>
           </packing>
         </child>
         </child>
       </widget>
       </widget>

+ 92 - 75
vies.phpw

@@ -2,11 +2,13 @@
 /**
 /**
  * A PHP-GTK2 UI for a SOAP client to the EU
  * A PHP-GTK2 UI for a SOAP client to the EU
  * VAT Information Exchange System (VIES) database
  * VAT Information Exchange System (VIES) database
- * (c) 2007 Frederic G. MARAND
+ *
+ * (c) 2007-2010 Frederic G. MARAND
+ *
  * Licensed under the CeCILL 2.0 license
  * Licensed under the CeCILL 2.0 license
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
  *
  *
- * $Id: vies.phpw,v 1.1 2007-04-09 16:27:57 marand Exp $
+ * $Id: vies.phpw,v 1.2 2010-09-21 09:05:15 fgm Exp $
  */
  */
 
 
 error_reporting(E_ALL|E_STRICT);
 error_reporting(E_ALL|E_STRICT);
@@ -14,55 +16,54 @@ error_reporting(E_ALL|E_STRICT);
 /**
 /**
  * Straight from the WSDL schema
  * Straight from the WSDL schema
  */
  */
-class checkVat
-  {
+class checkVat {
   /**
   /**
    * @var string
    * @var string
    */
    */
   var $countryCode;
   var $countryCode;
+
   /**
   /**
    * @var string
    * @var string
    */
    */
   var $vatNumber;
   var $vatNumber;
 
 
-  function __construct($cc, $vat)
-    {
+  function __construct($cc, $vat) {
     $this->countryCode = $cc;
     $this->countryCode = $cc;
     $this->vatNumber = $vat;
     $this->vatNumber = $vat;
-    }
   }
   }
+}
 
 
-class UI
-  {
+class UI {
   /**
   /**
    * @var GladeXML
    * @var GladeXML
    */
    */
   var $glade ;
   var $glade ;
 
 
-  function __construct()
-    {
+  function __construct() {
     $this->glade = new GladeXML('vies.glade');
     $this->glade = new GladeXML('vies.glade');
     $this->glade->signal_autoconnect_instance($this);
     $this->glade->signal_autoconnect_instance($this);
-    }
+  }
 
 
   /**
   /**
    * Return a widget from the loaded Glade file
    * Return a widget from the loaded Glade file
    *
    *
    * @param GtkWidget $name
    * @param GtkWidget $name
    */
    */
-  function get_widget($name)
-    {
+  function get_widget($name) {
     $ret = $this->glade->get_widget($name);
     $ret = $this->glade->get_widget($name);
     return $ret;
     return $ret;
-    }
+  }
 
 
-  function on_quit_action()
-    {
+  function on_quit_action() {
     Gtk::main_quit();
     Gtk::main_quit();
-    }
+  }
+
+  function on_pdc_about_activate() {
+    $dl = $this->get_widget('dl_about');
+    $dl->show();
+  }
 
 
-  function on_btn_clicked()
-    {
+  function on_btn_clicked() {
     $sb  = $this->get_widget('sb');
     $sb  = $this->get_widget('sb');
     $cc  = $this->get_widget('cb_country');
     $cc  = $this->get_widget('cb_country');
     $cc  = $cc->get_active_text();
     $cc  = $cc->get_active_text();
@@ -74,13 +75,11 @@ class UI
     $vat = $vat->get_text();
     $vat = $vat->get_text();
     /* var_dump($cc);
     /* var_dump($cc);
     var_dump($vat); */
     var_dump($vat); */
-    if (empty($cc) || empty($vat))
-      {
+    if (empty($cc) || empty($vat)) {
       $sb->push(0, 'You must choose a country and key in a VAT number.');
       $sb->push(0, 'You must choose a country and key in a VAT number.');
       yield();
       yield();
-      }
-    else
-      {
+    }
+    else {
       $nb = $this->get_widget('nb');
       $nb = $this->get_widget('nb');
       $nb->set_current_page(0);
       $nb->set_current_page(0);
       $sb->push(0, 'Invoking VIES web service. Please wait.');
       $sb->push(0, 'Invoking VIES web service. Please wait.');
@@ -89,14 +88,12 @@ class UI
       $sb->pop(0);
       $sb->pop(0);
       yield();
       yield();
 
 
-      if (!is_object($ret)) // An error occurred
-        {
+      if (!is_object($ret)) { // An error occurred
         $tv = $this->get_widget('tv');
         $tv = $this->get_widget('tv');
         $text_buffer->set_text($ret);
         $text_buffer->set_text($ret);
         $tv->set_buffer($text_buffer);
         $tv->set_buffer($text_buffer);
-        }
-      else // We got a result
-        {
+      }
+      else { // We got a result
         print_r($ret);
         print_r($ret);
         $val = $this->get_widget('lbCountryCodeVal');
         $val = $this->get_widget('lbCountryCodeVal');
         $val->set_text($ret->countryCode);
         $val->set_text($ret->countryCode);
@@ -108,14 +105,12 @@ class UI
         $val->set_text($ret->requestDate);
         $val->set_text($ret->requestDate);
 
 
         $val = $this->get_widget('imgValid');
         $val = $this->get_widget('imgValid');
-        if ($ret->valid)
-          {
+        if ($ret->valid) {
           $val->set_from_stock(Gtk::STOCK_YES, Gtk::ICON_SIZE_LARGE_TOOLBAR);
           $val->set_from_stock(Gtk::STOCK_YES, Gtk::ICON_SIZE_LARGE_TOOLBAR);
-          }
-        else
-          {
+        }
+        else {
           $val->set_from_stock(Gtk::STOCK_NO, Gtk::ICON_SIZE_LARGE_TOOLBAR);
           $val->set_from_stock(Gtk::STOCK_NO, Gtk::ICON_SIZE_LARGE_TOOLBAR);
-          }
+        }
         $val = $this->get_widget('lbNameVal');
         $val = $this->get_widget('lbNameVal');
         $val->set_text(empty($ret->name) ? '(not returned)' : $ret->name);
         $val->set_text(empty($ret->name) ? '(not returned)' : $ret->name);
 
 
@@ -123,68 +118,90 @@ class UI
         $val->set_text(empty($ret->address) ? '(not returned)' : $ret->address);
         $val->set_text(empty($ret->address) ? '(not returned)' : $ret->address);
 
 
         $nb->set_current_page(1);
         $nb->set_current_page(1);
-        }
-      yield();
       }
       }
+      yield();
     }
     }
+  }
 
 
-  function run()
-    {
+  function run() {
     $w = $this->get_widget('w');
     $w = $this->get_widget('w');
     $w->show_all();
     $w->show_all();
     Gtk::main();
     Gtk::main();
-    }
   }
   }
+}
 
 
-function yield()
-  {
-  while (Gtk::events_pending())
-    {
+function yield() {
+  while (Gtk::events_pending()) {
     Gtk::main_iteration();
     Gtk::main_iteration();
-    }
   }
   }
+}
+
+/**
+ * Make sure the code can proceed by checking requirements.
+ *
+ * - PHP version
+ * - PHP-GTK extension
+ * - SOAP extension
+ *
+ * @return void
+ */
+function checkRequirements() {
+  $ext = get_loaded_extensions();
+  if (version_compare(PHP_VERSION, '5.0.0') < 0) {
+    die('PHP >= 5.0 needed. Current version: '. PHP_VERSION);
+  }
+  if (!in_array('php-gtk', $ext)) {
+    die('Missing PHP-GTK extension. Aborting.');
+  }
+  if (!in_array('soap', $ext)) {
+    die('Missing SOAP extension. Aborting.');
+  }
+}
 
 
 /**
 /**
  * Invoke the VIES service to check an EU VAT number
  * Invoke the VIES service to check an EU VAT number
  *
  *
  * @param string $cc Country Code
  * @param string $cc Country Code
  * @param string $vat VAT number
  * @param string $vat VAT number
+ *
  * @return mixed
  * @return mixed
  */
  */
-function checkVat($cc, $vat)
-{
-$wsdl = 'http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl';
-
-$vies = new SoapClient($wsdl);
-/*
-var_dump($vies->__getFunctions());
-var_dump($vies->__getTypes());
-*/
-$nii = new checkVat($cc, $vat);
-
-try
-  {
-  $ret = $vies->checkVat($nii);
+function checkVat($cc, $vat) {
+  // 2007 URL
+  // $wsdl = 'http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl';
+
+  // 2010 URL
+  $wsdl = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
+
+  $vies = new SoapClient($wsdl);
+  /*
+  var_dump($vies->__getFunctions());
+  var_dump($vies->__getTypes());
+  */
+  $nii = new checkVat($cc, $vat);
+
+  try {
+    $ret = $vies->checkVat($nii);
   }
   }
-catch (SoapFault $e)
-  {
-  $ret = $e->faultstring;
-  $regex = '/\{ \'([A-Z_]*)\' \}/';
-  $n = preg_match($regex, $ret, $matches);
-  $ret = $matches[1];
-  $faults = array
-    (
-    'INVALID_INPUT'       => 'The provided CountryCode is invalid or the VAT number is empty',
-    'SERVICE_UNAVAILABLE' => 'The SOAP service is unavailable, try again later',
-    'MS_UNAVAILABLE'      => 'The Member State service is unavailable, try again later or with another Member State',
-    'TIMEOUT'             => 'The Member State service could not be reached in time, try again later or with another Member State',
-    'SERVER_BUSY'         => 'The service cannot process your request. Try again later.'
-    );
-  $ret = $faults[$ret];
+  catch (SoapFault $e) {
+    $ret = $e->faultstring;
+    $regex = '/\{ \'([A-Z_]*)\' \}/';
+    $n = preg_match($regex, $ret, $matches);
+    $ret = $matches[1];
+    $faults = array
+      (
+      'INVALID_INPUT'       => 'The provided CountryCode is invalid or the VAT number is empty',
+      'SERVICE_UNAVAILABLE' => 'The SOAP service is unavailable, try again later',
+      'MS_UNAVAILABLE'      => 'The Member State service is unavailable, try again later or with another Member State',
+      'TIMEOUT'             => 'The Member State service could not be reached in time, try again later or with another Member State',
+      'SERVER_BUSY'         => 'The service cannot process your request. Try again later.'
+      );
+    $ret = $faults[$ret];
   }
   }
 
 
 return $ret;
 return $ret;
 }
 }
 
 
+checkRequirements();
 $ui = new UI();
 $ui = new UI();
 $ui->run();
 $ui->run();

BIN
vies.png