Fix: uniformize code (in progress)

This commit is contained in:
Regis Houssin 2012-07-20 09:57:50 +02:00
parent 9f3f3703e3
commit fafd79a0f8
37 changed files with 337 additions and 380 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -12,28 +12,26 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/
*/ */
/** /**
* \file /marges/admin/marges.php * \file /htdocs/admin/margin.php
* \ingroup marges * \ingroup margin
* \brief Page to setup advanced extra fields module * \brief Page to setup margin module
* \version $Id:$
*/ */
$res=@include("../main.inc.php"); // For root directory include("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/marges/lib/marges.lib.php"); require_once(DOL_DOCUMENT_ROOT."/margin/lib/margins.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("marges"); $langs->load("margins");
if (!$user->admin) if (! $user->admin) accessforbidden();
accessforbidden();
$action=GETPOST('action','alpha');
/* /*
@ -67,7 +65,7 @@ if (preg_match('/del_(.*)/',$action,$reg))
} }
} }
if ($_POST["action"] == 'remises') if ($action == 'remises')
{ {
if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0)
{ {
@ -79,7 +77,7 @@ if ($_POST["action"] == 'remises')
} }
} }
if ($_POST["action"] == 'typemarges') if ($action == 'typemarges')
{ {
if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
{ {
@ -102,7 +100,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("margesSetup"),$linkback,'setup'); print_fiche_titre($langs->trans("margesSetup"),$linkback,'setup');
$head = marges_admin_prepare_head($adh); $head = marges_admin_prepare_head();
dol_fiche_head($head, 'parameters', $langs->trans("marges"), 0, 'company'); dol_fiche_head($head, 'parameters', $langs->trans("marges"), 0, 'company');
@ -130,11 +128,11 @@ print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("MARGIN_TYPE").'</td>'; print '<td>'.$langs->trans("MARGIN_TYPE").'</td>';
print '<td align="right">'.$langs->trans('MargeBrute'); print '<td align="right">'.$langs->trans('MargeBrute');
print ' <input type="radio" name="MARGIN_TYPE" value="1" '; print ' <input type="radio" name="MARGIN_TYPE" value="1" ';
if ($conf->global->MARGIN_TYPE == '1') if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1')
print 'checked '; print 'checked ';
print '/><br/>'.$langs->trans('MargeNette'); print '/><br/>'.$langs->trans('MargeNette');
print ' <input type="radio" name="MARGIN_TYPE" value="2" '; print ' <input type="radio" name="MARGIN_TYPE" value="2" ';
if ($conf->global->MARGIN_TYPE == '2') if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '2')
print 'checked '; print 'checked ';
print '/>'; print '/>';
print '</td>'; print '</td>';
@ -152,17 +150,17 @@ print '<td>'.$langs->trans("DisplayMarginRates").'</td>';
print '<td colspan="2" align="center">'; print '<td colspan="2" align="center">';
if ($conf->use_javascript_ajax) if (! empty($conf->use_javascript_ajax))
{ {
print ajax_constantonoff('DISPLAY_MARGIN_RATES'); print ajax_constantonoff('DISPLAY_MARGIN_RATES');
} }
else else
{ {
if($conf->global->DISPLAY_MARGIN_RATES == 0) if (empty($conf->global->DISPLAY_MARGIN_RATES))
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>';
} }
else if($conf->global->DISPLAY_MARGIN_RATES == 1) else
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>';
} }
@ -178,17 +176,17 @@ print '<td>'.$langs->trans("DisplayMarkRates").'</td>';
print '<td colspan="2" align="center">'; print '<td colspan="2" align="center">';
if ($conf->use_javascript_ajax) if (! empty($conf->use_javascript_ajax))
{ {
print ajax_constantonoff('DISPLAY_MARK_RATES'); print ajax_constantonoff('DISPLAY_MARK_RATES');
} }
else else
{ {
if($conf->global->DISPLAY_MARK_RATES == 0) if (empty($conf->global->DISPLAY_MARK_RATES))
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"),'off').'</a>';
} }
else if($conf->global->DISPLAY_MARK_RATES == 1) else
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"),'on').'</a>';
} }
@ -200,17 +198,17 @@ print '<tr>';
print '<td>'.$langs->trans("ForceBuyingPriceIfNull").'</td>'; print '<td>'.$langs->trans("ForceBuyingPriceIfNull").'</td>';
print '<td colspan="2" align="center">'; print '<td colspan="2" align="center">';
if ($conf->use_javascript_ajax) if (! empty($conf->use_javascript_ajax))
{ {
print ajax_constantonoff('ForceBuyingPriceIfNull'); print ajax_constantonoff('ForceBuyingPriceIfNull');
} }
else else
{ {
if($conf->global->ForceBuyingPriceIfNull == 0) if (empty($conf->global->ForceBuyingPriceIfNull))
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Disabled"),'off').'</a>';
} }
else if($conf->global->ForceBuyingPriceIfNull == 1) else
{ {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Enabled"),'on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull">'.img_picto($langs->trans("Enabled"),'on').'</a>';
} }
@ -229,15 +227,15 @@ print '<td>'.$langs->trans("MARGIN_METHODE_FOR_DISCOUNT").'</td>';
print '<td align="left">'; print '<td align="left">';
print '<select name="MARGIN_METHODE_FOR_DISCOUNT" >'; print '<select name="MARGIN_METHODE_FOR_DISCOUNT" >';
print '<option value="1" '; print '<option value="1" ';
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') if (isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT) && $conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1')
print 'selected '; print 'selected ';
print '>'.$langs->trans('UseDiscountAsProduct').'</option>'; print '>'.$langs->trans('UseDiscountAsProduct').'</option>';
print '<option value="2" '; print '<option value="2" ';
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') if (isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT) && $conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2')
print 'selected '; print 'selected ';
print '>'.$langs->trans('UseDiscountAsService').'</option>'; print '>'.$langs->trans('UseDiscountAsService').'</option>';
print '<option value="3" '; print '<option value="3" ';
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') if (isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT) && $conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3')
print 'selected '; print 'selected ';
print '>'.$langs->trans('UseDiscountOnTotal').'</option>'; print '>'.$langs->trans('UseDiscountOnTotal').'</option>';
print '</select>'; print '</select>';
@ -253,8 +251,6 @@ print '</table>';
print '<br>'; print '<br>';
llxFooter();
$db->close(); $db->close();
llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.6 $');
?> ?>

View File

@ -38,7 +38,7 @@ require_once(DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php');
require_once(DOL_DOCUMENT_ROOT."/core/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT."/core/modules/propale/modules_propale.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); if (! empty($conf->projet->enabled)) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
$langs->load('companies'); $langs->load('companies');
$langs->load('propal'); $langs->load('propal');
@ -46,8 +46,8 @@ $langs->load('compta');
$langs->load('bills'); $langs->load('bills');
$langs->load('orders'); $langs->load('orders');
$langs->load('products'); $langs->load('products');
if ($conf->marges->enabled) if (! empty($conf->margin->enabled))
$langs->load('marges'); $langs->load('margins');
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$ref=GETPOST('ref','alpha'); $ref=GETPOST('ref','alpha');
@ -456,7 +456,7 @@ else if ($action == 'setstatut' && $user->rights->propale->cloturer)
/* /*
* Add file in email form * Add file in email form
*/ */
if ($_POST['addfile']) if (GETPOST('addfile'))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@ -1562,7 +1562,7 @@ print '<td align="right" nowrap><b>'.price($object->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->currency).'</td>'; print '<td>'.$langs->trans("Currency".$conf->currency).'</td>';
// Margin Infos // Margin Infos
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
print '<td valign="top" width="50%" rowspan="4">'; print '<td valign="top" width="50%" rowspan="4">';
$object->displayMarginInfos(); $object->displayMarginInfos();
print '</td>'; print '</td>';

View File

@ -32,8 +32,7 @@
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT ."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT ."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT ."/margin/lib/margins.lib.php");
require_once(DOL_DOCUMENT_ROOT ."/marges/lib/marges.lib.php");
/** /**
* \class Propal * \class Propal
@ -2598,7 +2597,7 @@ class PropaleLigne
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseign<EFBFBD> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
@ -2736,7 +2735,7 @@ class PropaleLigne
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseign<EFBFBD> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);

View File

@ -28,8 +28,7 @@
*/ */
include_once(DOL_DOCUMENT_ROOT."/core/class/commonorder.class.php"); include_once(DOL_DOCUMENT_ROOT."/core/class/commonorder.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT ."/margin/lib/margins.lib.php");
require_once(DOL_DOCUMENT_ROOT ."/marges/lib/marges.lib.php");
/** /**
* \class Commande * \class Commande
@ -2999,7 +2998,7 @@ class OrderLine
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseign<EFBFBD> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
@ -3107,7 +3106,7 @@ class OrderLine
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseign<EFBFBD> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);

View File

@ -49,8 +49,8 @@ $langs->load('bills');
$langs->load('propal'); $langs->load('propal');
$langs->load('deliveries'); $langs->load('deliveries');
$langs->load('products'); $langs->load('products');
if ($conf->marges->enabled) if (! empty($conf->margin->enabled))
$langs->load('marges'); $langs->load('margins');
$id = (GETPOST('id','int')?GETPOST('id','int'):GETPOST("orderid")); $id = (GETPOST('id','int')?GETPOST('id','int'):GETPOST("orderid"));
$ref = GETPOST('ref'); $ref = GETPOST('ref');
@ -1989,7 +1989,7 @@ else
print '<td>'.$langs->trans('Currency'.$conf->currency).'</td>'; print '<td>'.$langs->trans('Currency'.$conf->currency).'</td>';
// Margin Infos // Margin Infos
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
print '<td valign="top" width="50%" rowspan="4">'; print '<td valign="top" width="50%" rowspan="4">';
$object->displayMarginInfos(); $object->displayMarginInfos();
print '</td>'; print '</td>';

View File

@ -51,8 +51,8 @@ $langs->load('bills');
$langs->load('companies'); $langs->load('companies');
$langs->load('products'); $langs->load('products');
$langs->load('main'); $langs->load('main');
if ($conf->marges->enabled) if (! empty($conf->margin->enabled))
$langs->load('marges'); $langs->load('margins');
$mesg=''; $mesg='';
$errors=array(); $errors=array();
@ -2766,7 +2766,7 @@ else if ($id > 0 || ! empty($ref))
print '</table>'; print '</table>';
// Margin Infos // Margin Infos
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
print '<br>'; print '<br>';
$object->displayMarginInfos($object->statut > 0); $object->displayMarginInfos($object->statut > 0);
} }

View File

@ -33,8 +33,7 @@
include_once(DOL_DOCUMENT_ROOT."/core/class/commoninvoice.class.php"); include_once(DOL_DOCUMENT_ROOT."/core/class/commoninvoice.class.php");
require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT ."/societe/class/client.class.php"); require_once(DOL_DOCUMENT_ROOT ."/societe/class/client.class.php");
require_once(DOL_DOCUMENT_ROOT ."/margin/lib/margins.lib.php");
require_once(DOL_DOCUMENT_ROOT ."/marges/lib/marges.lib.php");
/** /**
@ -3266,7 +3265,7 @@ class FactureLigne
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseign<EFBFBD> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
@ -3428,7 +3427,7 @@ class FactureLigne
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseigné et utilisé pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseign<EFBFBD> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);

View File

@ -2533,7 +2533,7 @@ abstract class CommonObject
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>'; print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>'; print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>'; print '<td align="right" width="50">'.$langs->trans('ReductionShort').'</td>';
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
if ($conf->global->MARGIN_TYPE == "1") if ($conf->global->MARGIN_TYPE == "1")
print '<td align="right" width="80">'.$langs->trans('BuyingPrice').'</td>'; print '<td align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
else else
@ -2870,20 +2870,20 @@ abstract class CommonObject
if ($conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) if ($conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0)
$line->pa_ht += $product->fourn_unitcharges; $line->pa_ht += $product->fourn_unitcharges;
} }
// si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente // si prix d'achat non renseign<EFBFBD> et devrait l'<27>tre, alors prix achat = prix vente
if ((!isset($line->pa_ht) || $line->pa_ht == 0) && ($conf->global->ForceBuyingPriceIfNull == 1)) { if ((!isset($line->pa_ht) || $line->pa_ht == 0) && ($conf->global->ForceBuyingPriceIfNull == 1)) {
$line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100)); $line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100));
} }
// calcul des marges // calcul des marges
if(isset($line->fk_remise_except)) { // remise if(isset($line->fk_remise_except)) { // remise
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale consid<EFBFBD>r<EFBFBD>e comme produit
$marginInfos['pa_products'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pa_products'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pv_products'] += $line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pv_products'] += $line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pv_total'] += $line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pv_total'] += $line->subprice * (1 - $line->remise_percent / 100);
} }
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale consid<EFBFBD>r<EFBFBD>e comme service
$marginInfos['pa_services'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pa_services'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
$marginInfos['pv_services'] += $line->subprice * (1 - ($line->remise_percent / 100)); $marginInfos['pv_services'] += $line->subprice * (1 - ($line->remise_percent / 100));
$marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100); $marginInfos['pa_total'] += ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);

View File

@ -328,8 +328,8 @@ function ajax_constantonoff($code,$input=array(),$entity=false)
}); });
</script>'; </script>';
$out.= '<span id="set_'.$code.'" class="linkobject '.($conf->global->$code?'hideobject':'').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>'; $out.= '<span id="set_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'hideobject':'').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.($conf->global->$code?'':'hideobject').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>'; $out.= '<span id="del_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'':'hideobject').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>';
return $out; return $out;
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -12,86 +12,76 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/** \defgroup mymodule Module MyModule /** \defgroup margin Module Margin
* \brief Example of a module descriptor. * \brief Example of a module descriptor.
* Such a file must be copied into htdocs/includes/module directory. * \file htdocs/includes/modules/modMargin.class.php
*/ * \ingroup margin
* \brief Description and activation file for module Margin
/**
* \file htdocs/includes/modules/modMyModule.class.php
* \ingroup mymodule
* \brief Description and activation file for module MyModule
* \version $Id: modMyModule.class.php,v 1.26 2008/12/15 18:27:00 eldy Exp $
*/ */
include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php"); include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
/** \class modMyModule /**
* \brief Description and activation class for module MyModule * \class modMargin
* \brief Description and activation class for module Margin
*/ */
class modMarges extends DolibarrModules class modMargin extends DolibarrModules
{ {
/** /**
* \brief Constructor. Define names, constants, directories, boxes, permissions * Constructor
* \param DB Database handler *
*/ * @param DoliDB $db Database handler
function modMarges($DB) */
function __construct($db)
{ {
$this->db = $DB; $this->db = $db;
// Id for module (must be unique). // Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 59000; $this->numero = 59000;
// Key text used to identify module (for permissions, menus, etc...) // Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'Marges'; $this->rights_class = 'margin';
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page // It is used to group modules in module setup page
$this->family = "financial"; $this->family = "financial";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = mb_ereg_replace('^mod','',get_class($this), "i"); $this->name = preg_replace('/^mod/i','',get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Gestion des marges"; $this->description = "Margin management";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = '2.0'; $this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=other) // Where to store the module in setup page (0=common,1=interface,2=other)
$this->special = 0; $this->special = 0;
// Name of png file (without png) used for this module. // Name of png file (without png) used for this module.
// Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
$this->picto='marges@marges'; $this->picto='marges';
// Data directories to create when module is enabled. // Data directories to create when module is enabled.
$this->dirs = array(); $this->dirs = array('/margin/temp');
//$this->dirs[0] = DOL_DATA_ROOT.'/Marges';
//$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp;
// Relative path to module style sheet if exists. Example: '/mymodule/mycss.css'.
$this->style_sheet = '/custom/marges/css/marges.css';
// Config pages. Put here list of php page names stored in admmin directory used to setup module. // Config pages. Put here list of php page names stored in admmin directory used to setup module.
$this->config_page_url = array("marges.php"); $this->config_page_url = array("margin.php");
// Dependencies // Dependencies
$this->depends = array("modPropale", "modProduct"); // List of modules id that must be enabled if this module is enabled $this->depends = array("modPropale", "modProduct"); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled $this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(4,1); // Minimum version of PHP required by module $this->phpmin = array(5,1); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3,1); // Minimum version of Dolibarr required by module $this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module
$this->langfiles = array("marges"); $this->langfiles = array("margins");
// Constants // Constants
$this->const = array(); // List of particular constants to add when module is enabled $this->const = array(); // List of particular constants to add when module is enabled
//$this->const = array( 0=>array('MAIN_MODULE_MARGES_HOOKS', 'chaine', 'propalcard', 'Hooks list for displaying Marges data on entity lists', 0, 'current', 1) );
// New pages on tabs // New pages on tabs
$this->tabs = array( $this->tabs = array(
'product:+marges:Marges:marges:/marges/tabs/productMargins.php?id=__ID__', 'product:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/productMargins.php?id=__ID__',
'thirdparty:+marges:Marges:marges:/marges/tabs/thirdpartyMargins.php?socid=__ID__', 'thirdparty:+margin:Margins:margins:$conf->margin->enabled:/margin/tabs/thirdpartyMargins.php?socid=__ID__'
); );
@ -99,94 +89,80 @@ class modMarges extends DolibarrModules
$this->boxes = array(); // List of boxes $this->boxes = array(); // List of boxes
$r=0; $r=0;
// Add here list of php file(s) stored in includes/boxes that contains class to show a box.
// Example:
//$this->boxes[$r][1] = "myboxa.php";
//$r++;
//$this->boxes[$r][1] = "myboxb.php";
//$r++;
// Permissions // Permissions
$this->rights = array(); // Permission array used by this module $this->rights = array(); // Permission array used by this module
$r=0; $r=0;
// Add here list of permission defined by an id, a label, a boolean and two constant strings.
// Example:
// $this->rights[$r][0] = 2000; // Permission id (must not be already used)
// $this->rights[$r][1] = 'Permision label'; // Permission label
// $this->rights[$r][3] = 1; // Permission by default for new user (0/1)
// $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
// $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
// $r++;
// Main menu entries // Main menu entries
$this->menu = array(); // List of menus to add $this->menu = array(); // List of menus to add
$r = 0; $r = 0;
// left menu entry // left menu entry
$this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu $this->menu[$r]=array(
'fk_menu'=>0, // Put 0 if this is a top menu
'type'=>'top', // This is a Top menu entry 'type'=>'top', // This is a Top menu entry
'titre'=>'Margins', 'titre'=>'Margins',
'mainmenu'=>'margins', 'mainmenu'=>'margins',
'leftmenu'=>'1', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). 'leftmenu'=>'1', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school).
'url'=>'/marges/index.php', 'url'=>'/margin/index.php',
'langs'=>'marges', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100, 'position'=>100,
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++; $r++;
// top menu entry // top menu entry
$this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) $this->menu[$r]=array(
'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
'type'=>'left', // This is a Left menu entry 'type'=>'left', // This is a Left menu entry
'titre'=>'ProductMargins', 'titre'=>'ProductMargins',
'mainmenu'=>'margins', 'mainmenu'=>'margins',
'url'=>'/marges/productMargins.php', 'url'=>'/margin/productMargins.php',
'langs'=>'marges', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100, 'position'=>100,
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2); // 0=Menu for internal users,1=external users, 2=both 'user'=>2); // 0=Menu for internal users,1=external users, 2=both
$r++; $r++;
$this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) $this->menu[$r]=array(
'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
'type'=>'left', // This is a Left menu entry 'type'=>'left', // This is a Left menu entry
'titre'=>'CustomerMargins', 'titre'=>'CustomerMargins',
'mainmenu'=>'margins', 'mainmenu'=>'margins',
'url'=>'/marges/customerMargins.php', 'url'=>'/margin/customerMargins.php',
'langs'=>'marges', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>200, 'position'=>200,
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2); // 0=Menu for internal users,1=external users, 2=both 'user'=>2); // 0=Menu for internal users,1=external users, 2=both
$r++; $r++;
$this->menu[$r]=array( 'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry) $this->menu[$r]=array(
'fk_menu'=>'r=0', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
'type'=>'left', // This is a Left menu entry 'type'=>'left', // This is a Left menu entry
'titre'=>'AgentMargins', 'titre'=>'AgentMargins',
'mainmenu'=>'margins', 'mainmenu'=>'margins',
'url'=>'/marges/agentMargins.php', 'url'=>'/margin/agentMargins.php',
'langs'=>'marges', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>300, 'position'=>300,
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2); // 0=Menu for internal users,1=external users, 2=both 'user'=>2); // 0=Menu for internal users,1=external users, 2=both
$r++; $r++;
}
}
/** /**
* \brief Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories. * It also creates data directories.
* \return int 1 if OK, 0 if KO *
* @return int 1 if OK, 0 if KO
*/ */
function init() function init()
{ {
@ -198,10 +174,11 @@ class modMarges extends DolibarrModules
} }
/** /**
* \brief Function called when module is disabled. * Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database. * Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted. * Data directories are not deleted.
* \return int 1 if OK, 0 if KO *
* @return int 1 if OK, 0 if KO
*/ */
function remove() function remove()
{ {
@ -212,15 +189,16 @@ class modMarges extends DolibarrModules
/** /**
* \brief Create tables and keys required by module * Create tables and keys required by module
* Files mymodule.sql and mymodule.key.sql with create table and create keys * Files mymodule.sql and mymodule.key.sql with create table and create keys
* commands must be stored in directory /mymodule/sql/ * commands must be stored in directory /mymodule/sql/
* This function is called by this->init. * This function is called by this->init.
* \return int <=0 if KO, >0 if OK *
*/ * @return int <=0 if KO, >0 if OK
function load_tables() */
function load_tables()
{ {
//return $this->_load_tables('/marges/sql/'); //return $this->_load_tables();
} }
} }

View File

@ -35,7 +35,7 @@
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td> <td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
<?php <?php
$colspan = 4; $colspan = 4;
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td> <td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
<?php <?php
@ -85,7 +85,7 @@ if ($conf->marges->enabled) {
<td align="right" nowrap><input type="text" size="1" value="<?php echo $buyer->remise_client; ?>" name="remise_percent">%</td> <td align="right" nowrap><input type="text" size="1" value="<?php echo $buyer->remise_client; ?>" name="remise_percent">%</td>
<?php <?php
$colspan = 4; $colspan = 4;
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"><input type="text" size="5" name="np_buying_price" value="<?php echo (isset($_POST["np_buying_price"])?$_POST["np_buying_price"]:''); ?>"></td> <td align="right"><input type="text" size="5" name="np_buying_price" value="<?php echo (isset($_POST["np_buying_price"])?$_POST["np_buying_price"]:''); ?>"></td>
<?php <?php
@ -104,7 +104,7 @@ if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
$colspan = 10; $colspan = 10;
else else
$colspan = 9; $colspan = 9;
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
if($conf->global->DISPLAY_MARGIN_RATES) if($conf->global->DISPLAY_MARGIN_RATES)
$colspan++; $colspan++;
if($conf->global->DISPLAY_MARK_RATES) if($conf->global->DISPLAY_MARK_RATES)

View File

@ -75,7 +75,7 @@
</td> </td>
<?php <?php
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"><input type="text" size="5" name="buying_price" value="<?php echo price($line->pa_ht,0,'',0); ?>"></td> <td align="right"><input type="text" size="5" name="buying_price" value="<?php echo price($line->pa_ht,0,'',0); ?>"></td>
<?php <?php

View File

@ -85,7 +85,7 @@
<td>&nbsp;</td> <td>&nbsp;</td>
<?php } <?php }
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right" nowrap="nowrap"><?php echo price($line->pa_ht); ?></td> <td align="right" nowrap="nowrap"><?php echo price($line->pa_ht); ?></td>
<?php if($conf->global->DISPLAY_MARGIN_RATES) {?> <?php if($conf->global->DISPLAY_MARGIN_RATES) {?>

View File

@ -42,7 +42,7 @@
<td align="right"><?php echo $langs->trans('ReductionShort'); ?></td> <td align="right"><?php echo $langs->trans('ReductionShort'); ?></td>
<?php <?php
$colspan = 4; $colspan = 4;
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td> <td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
<?php <?php
@ -92,7 +92,7 @@ jQuery(document).ready(function() {
<td align="right" nowrap><input type="text" size="1" name="remise_percent" value="<?php echo $buyer->remise_client; ?>">%</td> <td align="right" nowrap><input type="text" size="1" name="remise_percent" value="<?php echo $buyer->remise_client; ?>">%</td>
<?php <?php
$colspan = 4; $colspan = 4;
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"> <td align="right">
<select id="np_fournprice" name="np_fournprice" style="display: none;"></select> <select id="np_fournprice" name="np_fournprice" style="display: none;"></select>
@ -113,7 +113,7 @@ if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
$colspan = 10; $colspan = 10;
else else
$colspan = 9; $colspan = 9;
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
if($conf->global->DISPLAY_MARGIN_RATES) if($conf->global->DISPLAY_MARGIN_RATES)
$colspan++; $colspan++;
if($conf->global->DISPLAY_MARK_RATES) if($conf->global->DISPLAY_MARK_RATES)
@ -134,7 +134,7 @@ if ($conf->marges->enabled) {
</form> </form>
<?php <?php
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$("#idprod").change(function() { $("#idprod").change(function() {

View File

@ -84,7 +84,7 @@
<?php } ?> <?php } ?>
</td> </td>
<?php <?php
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"> <td align="right">
<select id="fournprice" name="fournprice"></select> <select id="fournprice" name="fournprice"></select>
@ -112,7 +112,7 @@ if ($conf->marges->enabled) {
</tr> </tr>
<?php } ?></form> <?php } ?></form>
<?php <?php
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {

View File

@ -54,7 +54,7 @@
<td>&nbsp;</td> <td>&nbsp;</td>
<?php } <?php }
if ($conf->marges->enabled) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right" nowrap="nowrap"><?php echo price($line->pa_ht); ?></td> <td align="right" nowrap="nowrap"><?php echo price($line->pa_ht); ?></td>
<?php if($conf->global->DISPLAY_MARGIN_RATES) {?> <?php if($conf->global->DISPLAY_MARGIN_RATES) {?>

View File

@ -1,4 +1,4 @@
# Dolibarr language file - fr_FR - marges # Dolibarr language file - fr_FR - margins
CHARSET=UTF-8 CHARSET=UTF-8
Margin=Marge Margin=Marge
@ -12,7 +12,7 @@ DisplayMarginRates=Afficher les taux de marge
DisplayMarkRates=Afficher les taux de marque DisplayMarkRates=Afficher les taux de marque
InputPrice=Saisir un prix InputPrice=Saisir un prix
marges=Gestion des marges margin=Gestion des marges
margesSetup=Paramétrage de la gestion des marges margesSetup=Paramétrage de la gestion des marges
MarginDetails=Détails des marges réalisées MarginDetails=Détails des marges réalisées

View File

@ -1,3 +0,0 @@
div.mainmenu.margins {
background : url('../img/marges.png') no-repeat 20px 0;
}

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,25 +16,24 @@
*/ */
/** /**
* \file htdocs/custom/marges/agentMargins.php * \file htdocs/margin/agentMargins.php
* \ingroup marges * \ingroup margin
* \brief Page des marges par agent commercial * \brief Page des marges par agent commercial
* \version $Id: facture.php,v 1.84 2011/08/08 16:07:47 eldy Exp $
*/ */
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/marges/lib/marges.lib.php"); require_once(DOL_DOCUMENT_ROOT."/margin/lib/margins.lib.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
$langs->load("marges"); $langs->load("margins");
// Security check // Security check
$agentid = isset($_REQUEST["agentid"])?$_REQUEST["agentid"]:''; $agentid = GETPOST('agentid','int');
$mesg = ''; $mesg = '';
@ -94,7 +93,7 @@ else {
if (! $sortfield) $sortfield="u.login"; if (! $sortfield) $sortfield="u.login";
} }
// Date début // Start date
print '<td>'.$langs->trans('StartDate').'</td>'; print '<td>'.$langs->trans('StartDate').'</td>';
print '<td width="20%">'; print '<td width="20%">';
$form->select_date($startdate,'startdate','','',1,"sel",1,1); $form->select_date($startdate,'startdate','','',1,"sel",1,1);
@ -253,12 +252,11 @@ else
} }
$db->free($result); $db->free($result);
$db->close();
llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $'); llxFooter();
$db->close();
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("#agentid").change(function() { $("#agentid").change(function() {
@ -270,5 +268,4 @@ $(document).ready(function() {
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>"); $("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
}); });
</script> </script>

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,26 +16,25 @@
*/ */
/** /**
* \file htdocs/custom/marges/customerMargins.php * \file htdocs/margin/customerMargins.php
* \ingroup marges * \ingroup margin
* \brief Page des marges par client * \brief Page des marges par client
* \version $Id: facture.php,v 1.84 2011/08/08 16:07:47 eldy Exp $
*/ */
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/marges/lib/marges.lib.php"); require_once(DOL_DOCUMENT_ROOT."/margin/lib/margins.lib.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
$langs->load("marges"); $langs->load("margins");
// Security check // Security check
$socid = isset($_REQUEST["socid"])?$_REQUEST["socid"]:''; $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id; if (! empty($user->societe_id)) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe','',''); $result = restrictedArea($user, 'societe','','');
@ -104,7 +103,7 @@ if (!$client) {
if (! $sortfield) $sortfield="s.nom"; if (! $sortfield) $sortfield="s.nom";
} }
// Date début // Start date
print '<td>'.$langs->trans('StartDate').'</td>'; print '<td>'.$langs->trans('StartDate').'</td>';
print '<td width="20%">'; print '<td width="20%">';
$form->select_date($startdate,'startdate','','',1,"sel",1,1); $form->select_date($startdate,'startdate','','',1,"sel",1,1);
@ -264,12 +263,11 @@ else
} }
$db->free($result); $db->free($result);
$db->close();
llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $'); llxFooter();
$db->close();
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("div.fiche form input.button['type=submit']").hide(); $("div.fiche form input.button['type=submit']").hide();
@ -283,5 +281,4 @@ $(document).ready(function() {
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>"); $("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
}); });
</script> </script>

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,9 +16,9 @@
*/ */
/** /**
* \file htdocs/custom/marges/index.php * \file htdocs/margin/index.php
* \ingroup product marges * \ingroup product margins
* \brief Page d'index du module marges * \brief Page d'index du module margin
*/ */
require("./productMargins.php"); require("./productMargins.php");

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -12,16 +12,13 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/
*/ */
/** /**
* \file /marges/lib/marges.lib.php * \file /htdocs/margin/lib/margins.lib.php
* \ingroup marges * \ingroup margin
* \brief Library for common marges functions * \brief Library for common margin functions
* \version $Id:$
*/ */
/** /**
@ -35,7 +32,7 @@ function marges_admin_prepare_head()
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = dol_buildpath("/marges/admin/marges.php",1); $head[$h][0] = DOL_URL_ROOT."/admin/margin.php";
$head[$h][1] = $langs->trans("Parameters"); $head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'parameters'; $head[$h][2] = 'parameters';
$h++; $h++;
@ -44,7 +41,7 @@ function marges_admin_prepare_head()
// Entries must be declared in modules descriptor with line // Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'margesadmin'); complete_head_from_modules($conf,$langs,'',$head,$h,'margesadmin');
return $head; return $head;
} }
@ -57,17 +54,17 @@ function marges_prepare_head($user)
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT."/marges/productMargins.php"; $head[$h][0] = DOL_URL_ROOT."/margin/productMargins.php";
$head[$h][1] = $langs->trans("ProductMargins"); $head[$h][1] = $langs->trans("ProductMargins");
$head[$h][2] = 'productMargins'; $head[$h][2] = 'productMargins';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/marges/customerMargins.php"; $head[$h][0] = DOL_URL_ROOT."/margin/customerMargins.php";
$head[$h][1] = $langs->trans("CustomerMargins"); $head[$h][1] = $langs->trans("CustomerMargins");
$head[$h][2] = 'customerMargins'; $head[$h][2] = 'customerMargins';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT."/marges/agentMargins.php"; $head[$h][0] = DOL_URL_ROOT."/margin/agentMargins.php";
$head[$h][1] = $langs->trans("AgentMargins"); $head[$h][1] = $langs->trans("AgentMargins");
$head[$h][2] = 'agentMargins'; $head[$h][2] = 'agentMargins';
$h++; $h++;
@ -78,30 +75,33 @@ function marges_prepare_head($user)
function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, $fk_pa, $paht) { function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, $fk_pa, $paht) {
global $db, $conf; global $db, $conf;
if($fk_pa > 0) { $marge_tx_ret='';
require_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php"; $marque_tx_ret='';
$product = new ProductFournisseur($db);
if ($product->fetch_product_fournisseur_price($fk_pa)) {
$paht_ret = $product->fourn_unitprice;
if ($conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0)
$paht_ret += $product->fourn_unitcharges;
}
else
$paht_ret = $paht;
}
else
$paht_ret = $paht;
require_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'); if($fk_pa > 0) {
// calcul pu_ht remisés require_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.product.class.php";
$tabprice=calcul_price_total(1, $pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', $objp->info_bits); $product = new ProductFournisseur($db);
if ($product->fetch_product_fournisseur_price($fk_pa)) {
$paht_ret = $product->fourn_unitprice;
if ($conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0)
$paht_ret += $product->fourn_unitcharges;
}
else
$paht_ret = $paht;
}
else
$paht_ret = $paht;
require_once(DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php');
// calcul pu_ht remisés
$tabprice=calcul_price_total(1, $pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT');
$pu_ht_remise = $tabprice[0]; $pu_ht_remise = $tabprice[0];
// calcul taux marge // calcul taux marge
if ($paht_ret != 0) if ($paht_ret != 0)
$marge_tx_ret = round((100 * ($pu_ht_remise - $paht_ret)) / $paht_ret, 3); $marge_tx_ret = round((100 * ($pu_ht_remise - $paht_ret)) / $paht_ret, 3);
// calcul taux marque // calcul taux marque
if ($pu_ht_remise != 0) if ($pu_ht_remise != 0)
$marque_tx_ret = round((100 * ($pu_ht_remise - $paht_ret)) / $pu_ht_remise, 3); $marque_tx_ret = round((100 * ($pu_ht_remise - $paht_ret)) / $pu_ht_remise, 3);
return array($paht_ret, $marge_tx_ret, $marque_tx_ret); return array($paht_ret, $marge_tx_ret, $marque_tx_ret);
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,31 +16,32 @@
*/ */
/** /**
* \file htdocs/custom/marges/productMargins.php * \file htdocs/margin/productMargins.php
* \ingroup marges * \ingroup margin
* \brief Page des marges par produit * \brief Page des marges par produit
* \version $Id: facture.php,v 1.84 2011/08/08 16:07:47 eldy Exp $
*/ */
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/marges/lib/marges.lib.php"); require_once(DOL_DOCUMENT_ROOT."/margin/lib/margins.lib.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
$langs->load("marges"); $langs->load("margins");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check // Security check
if (isset($_REQUEST["id"]) || isset($_REQUEST["ref"])) $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
{ $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
$id = isset($_REQUEST["id"])?$_REQUEST["id"]:(isset($_REQUEST["ref"])?$_REQUEST["ref"]:''); if (! empty($user->societe_id)) $socid=$user->societe_id;
} $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype);
$fieldid = isset($_REQUEST["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
$mesg = ''; $mesg = '';
@ -106,7 +107,7 @@ else {
if (! $sortfield) $sortfield="p.ref"; if (! $sortfield) $sortfield="p.ref";
} }
// Date début // Start date
print '<td>'.$langs->trans('StartDate').'</td>'; print '<td>'.$langs->trans('StartDate').'</td>';
print '<td width="20%">'; print '<td width="20%">';
$form->select_date($startdate,'startdate','','',1,"sel",1,1); $form->select_date($startdate,'startdate','','',1,"sel",1,1);
@ -271,12 +272,11 @@ else
} }
$db->free($result); $db->free($result);
$db->close();
llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $'); llxFooter();
$db->close();
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("#all").change(function() { $("#all").change(function() {
@ -292,5 +292,4 @@ $(document).ready(function() {
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>"); $("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
}); });
</script> </script>

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,10 +16,9 @@
*/ */
/** /**
* \file htdocs/custom/marges/tabs/productMargins.php * \file htdocs/margin/tabs/productMargins.php
* \ingroup product marges * \ingroup product margins
* \brief Page des marges des factures clients pour un produit * \brief Page des marges des factures clients pour un produit
* \version $Id: facture.php,v 1.84 2011/08/08 16:07:47 eldy Exp $
*/ */
require("../../main.inc.php"); require("../../main.inc.php");
@ -30,16 +29,20 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
$langs->load("marges"); $langs->load("margins");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check // Security check
if (isset($_GET["id"]) || isset($_GET["ref"])) $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
{ $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
$id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); if (! empty($user->societe_id)) $socid=$user->societe_id;
} $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype);
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id; $object = new Product($db);
$result=restrictedArea($user,'produit|service',$id,'product','','',$fieldid);
$mesg = ''; $mesg = '';
@ -60,29 +63,23 @@ if (! $sortfield) $sortfield="f.datef";
$invoicestatic=new Facture($db); $invoicestatic=new Facture($db);
$html = new Form($db); $form = new Form($db);
if ($_GET["id"] || $_GET["ref"]) if ($id > 0 || ! empty($ref))
{ {
$product = new Product($db); $result = $object->fetch($id, $ref);
if ($_GET["ref"])
{
$result = $product->fetch('',$_GET["ref"]);
$_GET["id"]=$product->id;
}
if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
llxHeader("","",$langs->trans("CardProduct".$product->type)); llxHeader("","",$langs->trans("CardProduct".$object->type));
/* /*
* En mode visu * En mode visu
*/ */
if ($result > 0) if ($result > 0)
{ {
$head=product_prepare_head($product, $user); $head=product_prepare_head($object, $user);
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($product->type==1?'service':'product'); $picto=($object->type==1?'service':'product');
dol_fiche_head($head, 'marges', $titre, 0, $picto); dol_fiche_head($head, 'marges', $titre, 0, $picto);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -90,22 +87,22 @@ if ($_GET["id"] || $_GET["ref"])
// Reference // Reference
print '<tr>'; print '<tr>';
print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $html->showrefnav($product,'ref','',1,'ref'); print $form->showrefnav($object,'ref','',1,'ref');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Libelle // Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td>'; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->libelle.'</td>';
print '</tr>'; print '</tr>';
// Status (to sell) // Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.'</td><td colspan="3">';
print $product->getLibStatut(2,0); print $object->getLibStatut(2,0);
print '</td></tr>'; print '</td></tr>';
// Status (to buy) // Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.'</td><td colspan="3">';
print $product->getLibStatut(2,1); print $object->getLibStatut(2,1);
print '</td></tr>'; print '</td></tr>';
// Total Margin // Total Margin
@ -144,7 +141,7 @@ if ($_GET["id"] || $_GET["ref"])
$sql.= " AND f.fk_statut > 0"; $sql.= " AND f.fk_statut > 0";
$sql.= " AND s.entity = ".$conf->entity; $sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND d.fk_facture = f.rowid";
$sql.= " AND d.fk_product =".$product->id; $sql.= " AND d.fk_product =".$object->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND f.fk_soc = $socid"; if ($socid) $sql.= " AND f.fk_soc = $socid";
$sql.= " ORDER BY $sortfield $sortorder "; $sql.= " ORDER BY $sortfield $sortorder ";
@ -155,7 +152,7 @@ if ($_GET["id"] || $_GET["ref"])
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=$product->id",$sortfield,$sortorder,'',$num,0,''); print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&amp;id=$object->id",$sortfield,$sortorder,'',$num,0,'');
$i = 0; $i = 0;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
@ -248,9 +245,9 @@ else
dol_print_error(); dol_print_error();
} }
$db->close();
llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $'); llxFooter();
$db->close();
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> /* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,10 +16,9 @@
*/ */
/** /**
* \file htdocs/custom/marges/tabs/thirdpartyMargins.php * \file htdocs/margin/tabs/thirdpartyMargins.php
* \ingroup product marges * \ingroup product margins
* \brief Page des marges des factures clients pour un tiers * \brief Page des marges des factures clients pour un tiers
* \version $Id: facture.php,v 1.84 2011/08/08 16:07:47 eldy Exp $
*/ */
require("../../main.inc.php"); require("../../main.inc.php");
@ -30,11 +29,11 @@ require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$langs->load("products"); $langs->load("products");
$langs->load("marges"); $langs->load("margins");
// Security check // Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:''; $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id; if (! empty($user->societe_id)) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe','',''); $result = restrictedArea($user, 'societe','','');
@ -234,9 +233,9 @@ else
dol_print_error(); dol_print_error();
} }
$db->close();
llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $'); llxFooter();
$db->close();
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B