diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3841183a7d1..930e1a2330c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -874,15 +874,23 @@ class Form * @param finished 2=all, 1=finished, 0=raw material * @param $selected_input_value Value of preselected input text (with ajax) */ - function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2,$selected_input_value='') + function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2,$selected_input_value='',$hidelabel=0) { global $langs,$conf; if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) { + if ($selected && empty($selected_input_value)) + { + require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); + $product = new Product($this->db); + $product->fetch($selected); + $selected_input_value=$product->ref; + } // mode=1 means customers products print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajaxproducts.php', 'outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); - print $langs->trans("RefOrLabel").' : '; + if (! $hidelabel) print $langs->trans("RefOrLabel").' : '; + print ''; print '
'; } else diff --git a/htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.mini.jgz b/htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.min.jgz similarity index 100% rename from htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.mini.jgz rename to htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.min.jgz diff --git a/htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.mini.js b/htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.min.js similarity index 100% rename from htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.mini.js rename to htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.min.js diff --git a/htdocs/paypal/admin/import.php b/htdocs/paypal/admin/import.php index c7edcba320c..d1dc27d7fe4 100755 --- a/htdocs/paypal/admin/import.php +++ b/htdocs/paypal/admin/import.php @@ -33,6 +33,9 @@ if (!$user->admin) $langs->load("paypal"); $langs->load("admin"); +$action=GETPOST('action'); +$idprod=GETPOST('idprod'); + /* * Actions @@ -65,6 +68,18 @@ if (preg_match('/del_(.*)/',$action,$reg)) } } +if ($action == 'setproductshippingcosts') +{ + if (dolibarr_set_const($db, 'PAYPAL_PRODUCT_SHIPPING_COSTS', $idprod, 'chaine', 0, '', $conf->entity) > 0) + { + Header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } +} /* * View @@ -120,6 +135,19 @@ print ' '; print ''.$langs->trans("Value").''."\n"; print ''; +$var=!$var; +print '
'; +print ''; +print ''; +print ''; +print ''.$langs->trans("DefaultProductShippingCosts").''; +print ''; +$form->select_produits($conf->global->PAYPAL_PRODUCT_SHIPPING_COSTS,'idprod','',$conf->product->limit_size,1,1,1,'',1); +print ''; +print ''; +print ''; +print '
'; + print ''; $db->close(); diff --git a/htdocs/paypal/ajaxtransaction.php b/htdocs/paypal/ajaxtransaction.php index 4b81b3599ad..0c4b4374182 100644 --- a/htdocs/paypal/ajaxtransaction.php +++ b/htdocs/paypal/ajaxtransaction.php @@ -160,6 +160,7 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti $object->date = dol_now(); $object->ref_ext = $_SESSION[$_GET['transaction_id']]['TRANSACTIONID']; + $shipamount = ($_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']?$_SESSION[$_GET['transaction_id']]['SHIPPINGAMT']:$_SESSION[$_GET['transaction_id']]['SHIPAMOUNT']); $object_id = $object->create($user); if ($object_id > 0) @@ -175,10 +176,9 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti if ($ret > 0) { $qty=$_SESSION[$_GET['transaction_id']]["L_QTY".$i]; - $product_type=($product->product_type?$product->product_type:0); - if ($subelement == 'commande') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,'HT',0,'','',$product_type); - if ($subelement == 'facture') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,'HT',0,$product_type); + if ($subelement == 'commande') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,0,'','',$product->product_type); + if ($subelement == 'facture') $fields = array($object_id,$product->description,$product->price,$qty,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,0,$product->product_type); $result = $object->addline($fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5],$fields[6],$fields[7],$fields[8],$fields[9],$fields[10],$fields[11],$fields[12],$fields[13],$fields[14],$fields[15],$fields[16]); @@ -199,6 +199,45 @@ if (isset($_GET['action']) && ! empty($_GET['action']) && isset($_GET['transacti $i++; } + + // Add shipping costs + if ($shipamount > 0) + { + if ($conf->global->PAYPAL_PRODUCT_SHIPPING_COSTS) + { + $product = new Product($db); + $ret = $product->fetch($conf->global->PAYPAL_PRODUCT_SHIPPING_COSTS); + + if ($ret > 0) + { + $product_type=($product->product_type?$product->product_type:0); + + if ($subelement == 'commande') $fields = array($object_id,$product->description,'',1,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,0,0,$product->price_base_type,$shipamount,'','',$product_type); + if ($subelement == 'facture') $fields = array($object_id,$product->description,'',1,$product->tva_tx,$product->localtax1_tx,$product->localtax2_tx,$product->id,0,'','',0,0,0,$product->price_base_type,$shipamount,$product_type); + + $result = $object->addline($fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5],$fields[6],$fields[7],$fields[8],$fields[9],$fields[10],$fields[11],$fields[12],$fields[13],$fields[14],$fields[15],$fields[16]); + + if ($result < 0) + { + $error++; + $langs->load("errors"); + $return_arr['error'] = ucfirst($subelement).'::addline '.$langs->trans($object->error); + break; + } + } + else + { + $error++; + $langs->load("errors"); + $return_arr['error'].= $langs->trans('ErrorProductWithRefNotExist', $conf->global->PAYPAL_PRODUCT_SHIPPING_COSTS).'
'; + } + } + else + { + $error++; + $return_arr['error'].= $langs->trans('ErrorUndefinedProductForShippingCost').'
'; + } + } } else {