Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2013-04-19 19:18:39 +02:00
commit eebbcbec57
4 changed files with 165 additions and 146 deletions

View File

@ -3048,10 +3048,15 @@ abstract class CommonObject
} }
/**
*
* @param string $force_price
* @return multitype:number string NULL
*/
function getMarginInfos($force_price=false) { function getMarginInfos($force_price=false) {
global $conf; global $conf;
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
$marginInfos = array( $marginInfos = array(
'pa_products' => 0, 'pa_products' => 0,
'pv_products' => 0, 'pv_products' => 0,
@ -3069,8 +3074,9 @@ abstract class CommonObject
'total_margin_rate' => '', 'total_margin_rate' => '',
'total_mark_rate' => '' 'total_mark_rate' => ''
); );
foreach($this->lines as $line) { foreach($this->lines as $line) {
if (isset($line->fk_fournprice) && !$force_price) { if (empty($line->pa_ht) && isset($line->fk_fournprice) && !$force_price) {
$product = new ProductFournisseur($this->db); $product = new ProductFournisseur($this->db);
if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) if ($product->fetch_product_fournisseur_price($line->fk_fournprice))
$line->pa_ht = $product->fourn_unitprice; $line->pa_ht = $product->fourn_unitprice;
@ -3130,7 +3136,6 @@ abstract class CommonObject
if ($marginInfos['pv_services'] > 0) if ($marginInfos['pv_services'] > 0)
$marginInfos['mark_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pv_services'],5); $marginInfos['mark_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pv_services'],5);
$marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total']; $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
if ($marginInfos['pa_total'] > 0) if ($marginInfos['pa_total'] > 0)
$marginInfos['total_margin_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pa_total'],5); $marginInfos['total_margin_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pa_total'],5);
@ -3140,9 +3145,15 @@ abstract class CommonObject
return $marginInfos; return $marginInfos;
} }
/**
*
* @param string $force_price
*/
function displayMarginInfos($force_price=false) { function displayMarginInfos($force_price=false) {
global $langs, $conf; global $langs, $conf;
$marginInfo = $this->getMarginInfos($force_price); $marginInfo = $this->getMarginInfos($force_price);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="30%">'.$langs->trans('Margins').'</td>'; print '<td width="30%">'.$langs->trans('Margins').'</td>';
@ -3191,6 +3202,6 @@ abstract class CommonObject
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
} }
}
}
?> ?>

View File

@ -80,8 +80,8 @@ if (! empty($conf->margin->enabled)) {
'origin_price_ht_cache' => 'price_ht', 'origin_price_ht_cache' => 'price_ht',
'origin_tva_tx_cache' => 'tva_tx', 'origin_tva_tx_cache' => 'tva_tx',
'origin_price_ttc_cache' => 'price_ttc', 'origin_price_ttc_cache' => 'price_ttc',
'qty' => 'qty' 'qty' => 'qty',
,'remise_percent' => 'discount' 'remise_percent' => 'discount'
), ),
'update_textarea' => array( 'update_textarea' => array(
'product_desc' => 'desc' 'product_desc' => 'desc'
@ -160,7 +160,10 @@ if (! empty($conf->margin->enabled)) {
<input type="hidden" id="origin_price_ttc_cache" name="origin_price_ttc_cache" value="" /> <input type="hidden" id="origin_price_ttc_cache" name="origin_price_ttc_cache" value="" />
</td> </td>
<td align="right"><input type="text" size="3" id="qty" name="qty" value="<?php echo (GETPOST('qty')?GETPOST('qty'):1); ?>"></td> <td align="right"><input type="text" size="3" id="qty" name="qty" value="<?php echo (GETPOST('qty')?GETPOST('qty'):1); ?>"></td>
<td align="right" nowrap="nowrap"><input type="text" size="1" value="<?php echo $buyer->remise_client; ?>" id="remise_percent" name="remise_percent">%</td> <td align="right" nowrap="nowrap">
<input type="text" size="1" value="<?php echo $buyer->remise_client; ?>" id="remise_percent" name="remise_percent">%
<input type="hidden" id="origin_remise_percent" name="origin_remise_percent" value="<?php echo $buyer->remise_client; ?>" />
</td>
<?php <?php
$colspan = 4; $colspan = 4;
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled)) {
@ -373,6 +376,11 @@ $(document).ready(function() {
$('#price_ttc').attr('disabled','disabled'); $('#price_ttc').attr('disabled','disabled');
} }
$('#remise_percent').bind('change', function() {
if ($(this).val() < $('#origin_remise_percent').val())
$('#remise_percent').val($('#origin_remise_percent').val());
});
$('#tva_tx').change(function() { $('#tva_tx').change(function() {
if ($(this).val() == 0) { if ($(this).val() == 0) {
if ($('#idprod').val() == 0) { if ($('#idprod').val() == 0) {

View File

@ -296,7 +296,7 @@ class ProductFournisseur extends Product
function fetch_product_fournisseur_price($rowid) function fetch_product_fournisseur_price($rowid)
{ {
$sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability,"; $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability,";
$sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.recuperableonly as fourn_tva_npr"; $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price
$sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql.= " WHERE pfp.rowid = ".$rowid; $sql.= " WHERE pfp.rowid = ".$rowid;
@ -320,7 +320,7 @@ class ProductFournisseur extends Product
$this->product_id = $obj->fk_product; // deprecated $this->product_id = $obj->fk_product; // deprecated
$this->fk_product = $obj->fk_product; $this->fk_product = $obj->fk_product;
$this->fk_availability = $obj->fk_availability; $this->fk_availability = $obj->fk_availability;
$this->fourn_tva_npr = $obj->fourn_tva_npr; //$this->fourn_tva_npr = $obj->fourn_tva_npr; // FIXME this field not exist in llx_product_fournisseur_price
return 1; return 1;
} }
else else

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -42,7 +42,7 @@ $hookmanager->initHooks(array('demo'));
$demoprofiles=array( $demoprofiles=array(
array('default'=>'1', 'key'=>'profdemoservonly','label'=>'DemoCompanyServiceOnly', array('default'=>'1', 'key'=>'profdemoservonly','label'=>'DemoCompanyServiceOnly',
'disablemodules'=>'adherent,barcode,boutique,cashdesk,categorie,don,expedition,externalsite,mailmanspip,prelevement,product,stock', 'disablemodules'=>'adherent,barcode,boutique,cashdesk,categorie,don,expedition,externalsite,mailmanspip,margin,prelevement,product,stock',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot8.png'), 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot8.png'),
array('default'=>'-1','key'=>'profdemoshopwithdesk','label'=>'DemoCompanyShopWithCashDesk', array('default'=>'-1','key'=>'profdemoshopwithdesk','label'=>'DemoCompanyShopWithCashDesk',
'disablemodules'=>'adherent,boutique,categorie,don,externalsite,ficheinter,mailmanspip,prelevement,product,stock', 'disablemodules'=>'adherent,boutique,categorie,don,externalsite,ficheinter,mailmanspip,prelevement,product,stock',
@ -54,10 +54,10 @@ $demoprofiles=array(
'disablemodules'=>'adherent,boutique,don,externalsite,mailmanspip', 'disablemodules'=>'adherent,boutique,don,externalsite,mailmanspip',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot9.png'), 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot9.png'),
array('default'=>'-1', 'key'=>'profdemofun','label'=>'DemoFundation', array('default'=>'-1', 'key'=>'profdemofun','label'=>'DemoFundation',
'disablemodules'=>'banque,barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,prelevement,product,projet,propal,propale,service,societe,stock,tax', 'disablemodules'=>'banque,barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,margin,prelevement,product,projet,propal,propale,service,societe,stock,tax',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png'), 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png'),
array('default'=>'0', 'key'=>'profdemofun2','label'=>'DemoFundation2', array('default'=>'0', 'key'=>'profdemofun2','label'=>'DemoFundation2',
'disablemodules'=>'barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,prelevement,product,projet,propal,propale,service,societe,stock,tax', 'disablemodules'=>'barcode,boutique,cashdesk,commande,commercial,compta,comptabilite,contrat,expedition,externalsite,facture,ficheinter,fournisseur,mailmanspip,margin,prelevement,product,projet,propal,propale,service,societe,stock,tax',
'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png') 'icon'=>DOL_URL_ROOT.'/public/demo/dolibarr_screenshot6.png')
); );