dolibarr  16.0.5
vatrates.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
23 if (!defined('NOTOKENRENEWAL')) {
24  define('NOTOKENRENEWAL', '1'); // Disables token renewal
25 }
26 if (!defined('NOREQUIREMENU')) {
27  define('NOREQUIREMENU', '1');
28 }
29 if (!defined('NOREQUIREAJAX')) {
30  define('NOREQUIREAJAX', '1');
31 }
32 
33 require '../../main.inc.php';
34 
35 $id = GETPOST('id', 'int');
36 $action = GETPOST('action', 'aZ09');
37 $htmlname = GETPOST('htmlname', 'alpha');
38 $selected = (GETPOST('selected') ?GETPOST('selected') : '-1');
39 $productid = (GETPOST('productid', 'int') ?GETPOST('productid', 'int') : 0);
40 
41 /*
42  * View
43  */
44 
45 top_httphead();
46 
47 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
48 
49 // Load original field value
50 if (!empty($id) && !empty($action) && !empty($htmlname)) {
51  $form = new Form($db);
52  $soc = new Societe($db);
53 
54  $soc->fetch($id);
55 
56  if ($action == 'getSellerVATRates') {
57  $seller = $mysoc;
58  $buyer = $soc;
59  } else {
60  $buyer = $mysoc;
61  $seller = $soc;
62  }
63 
64  $return = array();
65 
66  $return['value'] = $form->load_tva('tva_tx', $selected, $seller, $buyer, $productid, 0, '', true);
67  $return['num'] = $form->num;
68  $return['error'] = $form->error;
69 
70  echo json_encode($return);
71 }
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
top_httphead
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1407
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52