';
-$client = null;
+$client = false;
if ($socid > 0) {
- $societe = new Societe($db, $socid);
- $societe->fetch($socid);
+ $soc = new Societe($db, $socid);
+ $soc->fetch($socid);
- if ($societe->client)
- {
- print '| '.$langs->trans('ThirdPartyName').' | ';
- print '';
- $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1);
- print ' |
';
+ if ($soc->client)
+ {
+ print '| '.$langs->trans('ThirdPartyName').' | ';
+ print '';
+ $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1',1,0,1);
+ print ' |
';
- $client = true;
- if (! $sortorder) $sortorder="DESC";
- if (! $sortfield) $sortfield="f.datef";
- }
+ $client = true;
+ if (! $sortorder) $sortorder="DESC";
+ if (! $sortfield) $sortfield="f.datef";
+ }
}
-if (!$client) {
- print '| '.$langs->trans('ThirdPartyName').' | ';
- print '';
- $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1);
- print ' |
';
- if (! $sortorder) $sortorder="ASC";
- if (! $sortfield) $sortfield="s.nom";
+else {
+ print '| '.$langs->trans('ThirdPartyName').' | ';
+ print '';
+ $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid','client=1',1,0,1);
+ print ' |
';
}
// Start date
@@ -122,14 +124,14 @@ print ''; // set by jquery (see below)
print '';
// Margin Rate
-if ($conf->global->DISPLAY_MARGIN_RATES) {
+if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '| '.$langs->trans("MarginRate").' | ';
print ''; // set by jquery (see below)
print ' |
';
}
// Mark Rate
-if ($conf->global->DISPLAY_MARK_RATES) {
+if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '| '.$langs->trans("MarkRate").' | ';
print ''; // set by jquery (see below)
print ' |
';
@@ -169,25 +171,25 @@ if ($result)
$num = $db->num_rows($result);
print '
';
- print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,'');
+ print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'');
$i = 0;
print "";
print '';
- if ($client) {
- print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=".$_REQUEST["socid"],'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder);
+ if (! empty($client)) {
+ print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&socid=".$socid,'',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&socid=".$socid,'align="center"',$sortfield,$sortorder);
}
else
- print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&socid=".$_REQUEST["socid"],'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARGIN_RATES)
- print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARK_RATES)
- print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&socid=".$socid,'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
+ print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
+ print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$socid,'align="right"',$sortfield,$sortorder);
print "
\n";
$cumul_achat = 0;
@@ -224,9 +226,9 @@ if ($result)
print "".price($objp->selling_price)." | \n";
print "".price($objp->buying_price)." | \n";
print "".price($objp->marge)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print "\n";
$i++;
@@ -249,9 +251,9 @@ if ($result)
print "".price($cumul_vente)." | \n";
print "".price($cumul_achat)." | \n";
print "".price($totalMargin)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print "\n";
diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php
index 77368e80455..3456ee1e990 100644
--- a/htdocs/margin/lib/margins.lib.php
+++ b/htdocs/margin/lib/margins.lib.php
@@ -32,7 +32,7 @@ function marges_admin_prepare_head()
$h = 0;
$head = array();
- $head[$h][0] = DOL_URL_ROOT."/admin/margin.php";
+ $head[$h][0] = DOL_URL_ROOT."/margin/admin/margin.php";
$head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'parameters';
$h++;
diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php
index e43341ef7fc..ca6de009da3 100644
--- a/htdocs/margin/productMargins.php
+++ b/htdocs/margin/productMargins.php
@@ -47,12 +47,16 @@ $mesg = '';
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
+if (! $sortorder) $sortorder="ASC";
+if (! $sortfield) $sortfield="p.ref";
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
+$startdate=$enddate='';
+
if (!empty($_POST['startdatemonth']))
$startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']));
if (!empty($_POST['enddatemonth']))
@@ -76,7 +80,7 @@ print_fiche_titre($text);
// Show tabs
$head=marges_prepare_head($user);
$titre=$langs->trans("Margins");
-$picto='marges';
+$picto='margin';
dol_fiche_head($head, 'productMargins', $titre, 0, $picto);
print '';
-$sql = "SELECT distinct d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref,";
+$sql = "SELECT DISTINCT d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref,";
$sql.= " f.facnumber, f.total as total_ht,";
$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,";
$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ;
@@ -151,10 +151,10 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."product as p";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d";
-$sql.= " WHERE f.fk_soc = s.rowid";
+$sql.= " WHERE f.entity = ".$conf->entity;
+$sql.= " AND f.fk_soc = s.rowid";
$sql.= " AND d.fk_product = p.rowid";
$sql.= " AND f.fk_statut > 0";
-$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND d.fk_facture = f.rowid";
if ($id > 0)
$sql.= " AND d.fk_product =".$id;
@@ -174,26 +174,26 @@ if ($result)
{
$num = $db->num_rows($result);
- print '
';
- print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,'');
+ print '
';
+ print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,0,'');
$i = 0;
print "";
print '';
if ($id > 0) {
- print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$_REQUEST["id"],'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_REQUEST["id"],'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$id,'',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","",'align="center"',$sortfield,$sortorder);
}
else
- print_liste_field_titre($langs->trans("ProductService"),$_SERVER["PHP_SELF"],"p.ref","","&id=".$_REQUEST["id"],'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARGIN_RATES)
- print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARK_RATES)
- print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$_REQUEST["id"],'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("ProductService"),$_SERVER["PHP_SELF"],"p.ref","","&id=".$id,'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$id,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$id,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$id,'align="right"',$sortfield,$sortorder);
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
+ print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$id,'align="right"',$sortfield,$sortorder);
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
+ print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$id,'align="right"',$sortfield,$sortorder);
print "
\n";
$cumul_achat = 0;
@@ -213,29 +213,29 @@ if ($result)
print "";
if ($id > 0) {
- print '| ';
- $invoicestatic->id=$objp->facid;
- $invoicestatic->ref=$objp->facnumber;
- print $invoicestatic->getNomUrl(1);
- print " | \n";
- print "";
- print dol_print_date($db->jdate($objp->datef),'day')." | ";
- }
- else {
+ print '';
+ $invoicestatic->id=$objp->facid;
+ $invoicestatic->ref=$objp->facnumber;
+ print $invoicestatic->getNomUrl(1);
+ print " | \n";
+ print "";
+ print dol_print_date($db->jdate($objp->datef),'day')." | ";
+ }
+ else {
$product_static->type=$objp->fk_product_type;
- $product_static->id=$objp->fk_product;
+ $product_static->id=$objp->fk_product;
$product_static->ref=$objp->ref;
- $product_static->libelle=$objp->label;
+ $product_static->libelle=$objp->label;
$text=$product_static->getNomUrl(1);
$text.= ' - '.$objp->label;
- print "".$product_static->getNomUrl(1)." | \n";
- }
+ print "".$product_static->getNomUrl(1)." | \n";
+ }
print "".price($objp->selling_price)." | \n";
print "".price($objp->buying_price)." | \n";
print "".price($objp->marge)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print "
\n";
$i++;
@@ -251,20 +251,20 @@ if ($result)
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ;
print '';
if ($id > 0)
- print '| ';
- else
- print ' | ';
- print $langs->trans('TotalMargin')." | ";
+ print '';
+ else
+ print ' | ';
+ print $langs->trans('TotalMargin')." | ";
print "".price($cumul_vente)." | \n";
print "".price($cumul_achat)." | \n";
print "".price($totalMargin)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print "
\n";
- print "
";
+ print "
";
}
else
{
@@ -287,9 +287,9 @@ $(document).ready(function() {
$("div.fiche form").submit();
});
- $("#totalMargin").html("");
- $("#marginRate").html("");
- $("#markRate").html("");
+ $("#totalMargin").html("");
+ $("#marginRate").html("");
+ $("#markRate").html("");
});
\ No newline at end of file
diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php
index e13e6b036d8..9c452973710 100644
--- a/htdocs/margin/tabs/productMargins.php
+++ b/htdocs/margin/tabs/productMargins.php
@@ -80,7 +80,7 @@ if ($id > 0 || ! empty($ref))
$head=product_prepare_head($object, $user);
$titre=$langs->trans("CardProduct".$object->type);
$picto=($object->type==1?'service':'product');
- dol_fiche_head($head, 'marges', $titre, 0, $picto);
+ dol_fiche_head($head, 'margin', $titre, 0, $picto);
print '';
@@ -111,14 +111,14 @@ if ($id > 0 || ! empty($ref))
print '';
// Margin Rate
- if ($conf->global->DISPLAY_MARGIN_RATES) {
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '| '.$langs->trans("MarginRate").' | ';
print ''; // set by jquery (see below)
print ' |
';
}
// Mark Rate
- if ($conf->global->DISPLAY_MARK_RATES) {
+ if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '| '.$langs->trans("MarkRate").' | ';
print ''; // set by jquery (see below)
print ' |
';
@@ -128,7 +128,7 @@ if ($id > 0 || ! empty($ref))
print '';
- $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";
+ $sql = "SELECT DISTINCT s.nom, s.rowid as socid, s.code_client,";
$sql.= " f.facnumber, f.total as total_ht,";
$sql.= " (d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price, (d.buy_price_ht * d.qty) as buying_price, d.qty, ((d.subprice - d.buy_price_ht) * d.qty) as marge," ;
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
@@ -143,7 +143,7 @@ if ($id > 0 || ! empty($ref))
$sql.= " AND d.fk_facture = f.rowid";
$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 ($socid) $sql.= " AND f.fk_soc = $socid";
+ if (! empty($socid)) $sql.= " AND f.fk_soc = $socid";
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= $db->plimit($conf->liste_limit +1, $offset);
@@ -158,19 +158,19 @@ if ($id > 0 || ! empty($ref))
print "";
print '';
- print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$_GET["id"],'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$_GET["id"],'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$_GET["id"],'',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$_GET["id"],'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARGIN_RATES)
- print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARK_RATES)
- print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$_GET["id"],'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Invoice"),$_SERVER["PHP_SELF"],"f.facnumber","","&id=".$object->id,'',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","","&id=".$object->id,'',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("CustomerCode"),$_SERVER["PHP_SELF"],"s.code_client","","&id=".$object->id,'',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("DateInvoice"),$_SERVER["PHP_SELF"],"f.datef","","&id=".$object->id,'align="center"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Qty"),$_SERVER["PHP_SELF"],"d.qty","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
+ print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
+ print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&id=".$object->id,'align="right"',$sortfield,$sortorder);
print "
\n";
$cumul_achat = 0;
@@ -200,9 +200,9 @@ if ($id > 0 || ! empty($ref))
print "".price($objp->buying_price)." | \n";
print "".price($objp->qty)." | \n";
print "".price($objp->marge)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).' | ';
print "\n";
@@ -224,9 +224,9 @@ if ($id > 0 || ! empty($ref))
print "".price($cumul_achat)." | \n";
print "".price($cumul_qty)." | \n";
print "".price($totalMargin)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print ' | ';
print "\n";
diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php
index 2e94ed9b1e0..0ea0f42acad 100644
--- a/htdocs/margin/tabs/thirdpartyMargins.php
+++ b/htdocs/margin/tabs/thirdpartyMargins.php
@@ -71,7 +71,7 @@ if ($socid > 0)
$head = societe_prepare_head($societe);
- dol_fiche_head($head, 'marges', $langs->trans("ThirdParty"),0,'company');
+ dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company');
print '';
@@ -109,14 +109,14 @@ if ($socid > 0)
print '';
// Margin Rate
- if ($conf->global->DISPLAY_MARGIN_RATES) {
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '| '.$langs->trans("MarginRate").' | ';
print ''; // set by jquery (see below)
print ' |
';
}
// Mark Rate
- if ($conf->global->DISPLAY_MARK_RATES) {
+ if (! empty($conf->global->DISPLAY_MARK_RATES)) {
print '| '.$langs->trans("MarkRate").' | ';
print ''; // set by jquery (see below)
print ' |
';
@@ -158,9 +158,9 @@ if ($socid > 0)
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"f.paye,f.fk_statut","","&socid=".$_REQUEST["socid"],'align="right"',$sortfield,$sortorder);
print "\n";
@@ -191,9 +191,9 @@ if ($socid > 0)
print "".price($objp->selling_price)." | \n";
print "".price($objp->buying_price)." | \n";
print "".price($objp->marge)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).' | ';
print "\n";
@@ -213,9 +213,9 @@ if ($socid > 0)
print "".price($cumul_vente)." | \n";
print "".price($cumul_achat)." | \n";
print "".price($totalMargin)." | \n";
- if ($conf->global->DISPLAY_MARGIN_RATES)
+ if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print "".(($marginRate === '')?'n/a':price($marginRate)."%")." | \n";
- if ($conf->global->DISPLAY_MARK_RATES)
+ if (! empty($conf->global->DISPLAY_MARK_RATES))
print "".(($markRate === '')?'n/a':price($markRate)."%")." | \n";
print ' | ';
print "\n";
diff --git a/htdocs/product/ajaxproducts.php b/htdocs/product/ajaxproducts.php
index 7f209839da5..1e99dcb7a8c 100644
--- a/htdocs/product/ajaxproducts.php
+++ b/htdocs/product/ajaxproducts.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005-2011 Regis Houssin
+ * Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2007-2011 Laurent Destailleur
*
* This program is free software; you can redistribute it and/or modify
@@ -60,12 +60,12 @@ if (! isset($_GET['htmlname'])) return;
$htmlname = $_GET['htmlname'];
$match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET));
sort($match);
-$idprod = $match[0];
+$idprod = (! empty($match[0]) ? $match[0] : '');
if (! isset($_GET[$htmlname]) && ! isset($_GET[$idprod])) return;
// When used from jQuery, the search term is added as GET param "term".
-$searchkey=$_GET[$idprod];
+$searchkey=(! empty($_GET[$idprod])?$_GET[$idprod]:'');
if (empty($searchkey)) $searchkey=$_GET[$htmlname];
$outjson=isset($_GET['outjson'])?$_GET['outjson']:0;
diff --git a/htdocs/theme/amarok/img/commissions.png b/htdocs/theme/amarok/img/commissions.png
deleted file mode 100644
index b1e139e3fba..00000000000
Binary files a/htdocs/theme/amarok/img/commissions.png and /dev/null differ
diff --git a/htdocs/theme/amarok/img/marges.png b/htdocs/theme/amarok/img/marges.png
deleted file mode 100644
index 4746f0fc779..00000000000
Binary files a/htdocs/theme/amarok/img/marges.png and /dev/null differ
diff --git a/htdocs/theme/amarok/img/object_marges.png b/htdocs/theme/amarok/img/object_margin.png
similarity index 100%
rename from htdocs/theme/amarok/img/object_marges.png
rename to htdocs/theme/amarok/img/object_margin.png
diff --git a/htdocs/theme/auguria/img/commissions.png b/htdocs/theme/auguria/img/commissions.png
deleted file mode 100644
index b1e139e3fba..00000000000
Binary files a/htdocs/theme/auguria/img/commissions.png and /dev/null differ
diff --git a/htdocs/theme/auguria/img/marges.png b/htdocs/theme/auguria/img/marges.png
deleted file mode 100644
index 4746f0fc779..00000000000
Binary files a/htdocs/theme/auguria/img/marges.png and /dev/null differ
diff --git a/htdocs/theme/auguria/img/object_marges.png b/htdocs/theme/auguria/img/object_margin.png
similarity index 100%
rename from htdocs/theme/auguria/img/object_marges.png
rename to htdocs/theme/auguria/img/object_margin.png
diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php
index 40d0578c68e..b7340ef3e2b 100644
--- a/htdocs/theme/auguria/style.css.php
+++ b/htdocs/theme/auguria/style.css.php
@@ -320,7 +320,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'=
'barcode'=>'','fckeditor'=>'','categorie'=>'',
);
$mainmenuused='home';
-foreach($conf->modules as $key => $val)
+foreach($conf->modules as $val)
{
$mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val);
}
@@ -331,7 +331,7 @@ $mainmenuusedarray=array(); // Disable
$generic=1;
$divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','ecm','cashdesk');
-foreach($mainmenuusedarray as $key => $val)
+foreach($mainmenuusedarray as $val)
{
if (empty($val) || in_array($val,$divalreadydefined)) continue;
//print "XXX".$val;
diff --git a/htdocs/theme/bureau2crea/img/commissions.png b/htdocs/theme/bureau2crea/img/commissions.png
deleted file mode 100644
index b1e139e3fba..00000000000
Binary files a/htdocs/theme/bureau2crea/img/commissions.png and /dev/null differ
diff --git a/htdocs/theme/bureau2crea/img/marges.png b/htdocs/theme/bureau2crea/img/marges.png
deleted file mode 100644
index 4746f0fc779..00000000000
Binary files a/htdocs/theme/bureau2crea/img/marges.png and /dev/null differ
diff --git a/htdocs/theme/bureau2crea/img/object_marges.png b/htdocs/theme/bureau2crea/img/object_margin.png
similarity index 100%
rename from htdocs/theme/bureau2crea/img/object_marges.png
rename to htdocs/theme/bureau2crea/img/object_margin.png
diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php
index 6183a246a83..d8ab2f33920 100644
--- a/htdocs/theme/bureau2crea/style.css.php
+++ b/htdocs/theme/bureau2crea/style.css.php
@@ -383,7 +383,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'=
'barcode'=>'','fckeditor'=>'','categorie'=>'',
);
$mainmenuused='home';
-foreach($conf->modules as $key => $val)
+foreach($conf->modules as $val)
{
$mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val);
}
@@ -394,7 +394,7 @@ $mainmenuusedarray=array(); // Disable
$generic=1;
$divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','ecm','cashdesk');
-foreach($mainmenuusedarray as $key => $val)
+foreach($mainmenuusedarray as $val)
{
if (empty($val) || in_array($val,$divalreadydefined)) continue;
//print "XXX".$val;
diff --git a/htdocs/theme/cameleo/img/commissions.png b/htdocs/theme/cameleo/img/commissions.png
deleted file mode 100644
index b1e139e3fba..00000000000
Binary files a/htdocs/theme/cameleo/img/commissions.png and /dev/null differ
diff --git a/htdocs/theme/cameleo/img/marges.png b/htdocs/theme/cameleo/img/marges.png
deleted file mode 100644
index 4746f0fc779..00000000000
Binary files a/htdocs/theme/cameleo/img/marges.png and /dev/null differ
diff --git a/htdocs/theme/cameleo/img/object_marges.png b/htdocs/theme/cameleo/img/object_margin.png
similarity index 100%
rename from htdocs/theme/cameleo/img/object_marges.png
rename to htdocs/theme/cameleo/img/object_margin.png
diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php
index a63f1e04636..78121b403c0 100644
--- a/htdocs/theme/cameleo/style.css.php
+++ b/htdocs/theme/cameleo/style.css.php
@@ -467,7 +467,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'=
'barcode'=>'','fckeditor'=>'','categorie'=>'',
);
$mainmenuused='home';
-foreach($conf->modules as $key => $val)
+foreach($conf->modules as $val)
{
$mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val);
}
@@ -476,7 +476,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused));
$generic=1;
$divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','ecm','bookmark','cashdesk','geoipmaxmind','gravatar','clicktodial','paypal','webservices');
-foreach($mainmenuusedarray as $key => $val)
+foreach($mainmenuusedarray as $val)
{
if (empty($val) || in_array($val,$divalreadydefined)) continue;
//print "XXX".$val;
diff --git a/htdocs/theme/eldy/img/commissions.png b/htdocs/theme/eldy/img/commissions.png
deleted file mode 100644
index b1e139e3fba..00000000000
Binary files a/htdocs/theme/eldy/img/commissions.png and /dev/null differ
diff --git a/htdocs/theme/eldy/img/marges.png b/htdocs/theme/eldy/img/marges.png
deleted file mode 100644
index 4746f0fc779..00000000000
Binary files a/htdocs/theme/eldy/img/marges.png and /dev/null differ
diff --git a/htdocs/theme/eldy/img/menus/marges.png b/htdocs/theme/eldy/img/menus/marges.png
deleted file mode 100644
index 4746f0fc779..00000000000
Binary files a/htdocs/theme/eldy/img/menus/marges.png and /dev/null differ
diff --git a/htdocs/theme/eldy/img/object_marges.png b/htdocs/theme/eldy/img/object_margin.png
similarity index 100%
rename from htdocs/theme/eldy/img/object_marges.png
rename to htdocs/theme/eldy/img/object_margin.png
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 326da714425..b8470e3c090 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -628,7 +628,7 @@ $moduletomainmenu=array('user'=>'','syslog'=>'','societe'=>'companies','projet'=
'barcode'=>'','fckeditor'=>'','categorie'=>'',
);
$mainmenuused='home';
-foreach($conf->modules as $key => $val)
+foreach($conf->modules as $val)
{
$mainmenuused.=','.(isset($moduletomainmenu[$val])?$moduletomainmenu[$val]:$val);
}
@@ -637,7 +637,7 @@ $mainmenuusedarray=array_unique(explode(',',$mainmenuused));
$generic=1;
$divalreadydefined=array('home','companies','products','commercial','accountancy','project','tools','members','shop','agenda','bookmark','cashdesk','ecm','geoipmaxmind','gravatar','clicktodial','paypal','webservices');
-foreach($mainmenuusedarray as $key => $val)
+foreach($mainmenuusedarray as $val)
{
if (empty($val) || in_array($val,$divalreadydefined)) continue;
//print "XXX".$val;
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index fe6650d4203..a78b4a91f55 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -531,7 +531,7 @@ class User extends CommonObject
if ($perms)
{
- if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error
+ if (! isset($this->rights) || ! is_object($this->rights)) $this->rights = (object) array(); // For avoid error
if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array();
if ($subperms)
{
@@ -578,7 +578,7 @@ class User extends CommonObject
if ($perms)
{
- if (! isset($this->rights)) $this->rights = (object) array(); // For avoid error
+ if (! isset($this->rights) || ! is_object($this->rights)) $this->rights = (object) array(); // For avoid error
if (! isset($this->rights->$module) || ! is_object($this->rights->$module)) $this->rights->$module = (object) array();
if ($subperms)
{
diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php
index 9e67019dacc..1cc04f3c1a7 100755
--- a/htdocs/webservices/server_invoice.php
+++ b/htdocs/webservices/server_invoice.php
@@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
dol_syslog("Call Dolibarr webservices interfaces");
-$langs->load("main");
+$langs->load("main");
// Enable and test if module web services is enabled
if (empty($conf->global->MAIN_MODULE_WEBSERVICES))