Grzesiu Posted February 9, 2010 Share Posted February 9, 2010 Now I'm checking Action Hooks (Valid Tax/VAT ID Number). But it doesn't work correct. Does hook ClientAdd, ClientEdit work after client was adding to the base (or when new data was saved) or action is concurrent? Function setTaxExemptForVAT from script vatnumbervalidation not always change taxexempt on. It looks like update_query("tblclients",array("taxexempt"=>"on"),array("id"=>$vars["userid"])); can't find client in base. Maybe like he wasn't added yet. 0 Quote Link to comment Share on other sites More sharing options...
HerrZ Posted February 10, 2010 Share Posted February 10, 2010 when new data is saved by an updatequery (somewhere in your code), the hook ClientEdit probably will not called. The Hook Client Edit is called on the Editform in clientarea ( clientarea.php?action=details ) when saving. Tip: add in the hook ClientEdit: die("this is the die in ClientEdit Hook "); Then you will see, if its called. 0 Quote Link to comment Share on other sites More sharing options...
Grzesiu Posted February 10, 2010 Author Share Posted February 10, 2010 Then you will see, if its called. OK, Hook vatnumbervalidation does not work Please change the function of setTaxExemptForVAT function setTaxExemptForVAT($vars) { global $VAT_CUSTOM_FIELD_NAME,$VAT_HOME_COUNTRY; $result = select_query("tblcustomfields","id",array("type"=>"client","fieldname"=>$VAT_CUSTOM_FIELD_NAME)); $data = mysql_fetch_array($result); $VAT_CUSTOM_FIELD_ID = $data["id"]; $result = select_query("tblcustomfieldsvalues","value",array("fieldid"=>$VAT_CUSTOM_FIELD_ID,"relid"=>$vars["userid"])); $data = mysql_fetch_array($result); $VAT_CUSTOM_FIELD_VALUE = $data["value"]; if (!$VAT_CUSTOM_FIELD_VALUE) { die ("VAT Number not found, id: $VAT_CUSTOM_FIELD_ID fieldid: $VAT_CUSTOM_FIELD_VALUE"); } $european_union_countries = array('AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK'); if ((in_array($vars["country"],$european_union_countries))AND($vars["country"]!=$VAT_HOME_COUNTRY)AND($VAT_CUSTOM_FIELD_VALUE)) { update_query("tblclients",array("taxexempt"=>"on"),array("id"=>$vars["userid"])); } } And set up a new user with a valid VAT number 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.