Fix: uniformize code
@ -200,7 +200,7 @@ print $langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1));
|
||||
if ($nbofactivatedmodules <= 1) print ' '.img_warning($langs->trans("YouMustEnableOneModule"));
|
||||
print '<br>'."\n";
|
||||
|
||||
print "<br>\n";
|
||||
print "<br>\n";
|
||||
|
||||
$h = 0;
|
||||
|
||||
|
||||
@ -928,7 +928,7 @@ else
|
||||
print '<br><br></div>';
|
||||
}
|
||||
|
||||
if (! empty($mesgembedded)) dol_htmloutput_mesg($mesgembedded,'','warning',1);
|
||||
if (! empty($mesgembedded)) dol_htmloutput_mesg($mesgembedded,'','warning',1);
|
||||
|
||||
// Affichage formulaire de TEST
|
||||
if ($action == 'test')
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -12,9 +12,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -23,33 +21,24 @@
|
||||
* \brief Page to setup advanced commissions module
|
||||
*/
|
||||
|
||||
$res=@include("../main.inc.php"); // For root directory
|
||||
|
||||
include("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commissions/lib/commissions.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("commissions");
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
// init
|
||||
if ($conf->global->COMMISSION_BASE == "") {
|
||||
if ($conf->marges->enabled)
|
||||
$conf->global->COMMISSION_BASE = "MARGES";
|
||||
else
|
||||
$conf->global->COMMISSION_BASE = "CA";
|
||||
}
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
if (isset($_POST['commissionBase']))
|
||||
if (GETPOST('commissionBase'))
|
||||
{
|
||||
if (dolibarr_set_const($db, 'COMMISSION_BASE', $_POST['commissionBase'], 'string', 0, '', $conf->entity) > 0)
|
||||
if (dolibarr_set_const($db, 'COMMISSION_BASE', GETPOST('commissionBase'), 'string', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
$conf->global->COMMISSION_BASE = $_POST['commissionBase'];
|
||||
$conf->global->COMMISSION_BASE = GETPOST('commissionBase');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -57,9 +46,9 @@ if (isset($_POST['commissionBase']))
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['productCommissionRate']))
|
||||
if (GETPOST('productCommissionRate'))
|
||||
{
|
||||
if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', $_POST['productCommissionRate'], 'rate', 0, '', $conf->entity) > 0)
|
||||
if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', GETPOST('productCommissionRate'), 'rate', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
@ -68,9 +57,9 @@ if (isset($_POST['productCommissionRate']))
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['serviceCommissionRate']))
|
||||
if (GETPOST('serviceCommissionRate'))
|
||||
{
|
||||
if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', $_POST['serviceCommissionRate'], 'rate', 0, '', $conf->entity) > 0)
|
||||
if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', GETPOST('serviceCommissionRate'), 'rate', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
@ -91,7 +80,7 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
|
||||
print_fiche_titre($langs->trans("commissionsSetup"),$linkback,'setup');
|
||||
|
||||
|
||||
$head = commissions_admin_prepare_head($adh);
|
||||
$head = commissions_admin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'parameters', $langs->trans("Commissions"), 0, 'commissions');
|
||||
|
||||
@ -111,21 +100,21 @@ $form = new Form($db);
|
||||
|
||||
print '<form method="post">';
|
||||
|
||||
// COMMISSION BASE (CA / MARGES)
|
||||
// COMMISSION BASE (TURNOVER / MARGIN)
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("CommissionBase").'</td>';
|
||||
print '<td align="left">';
|
||||
print '<input type="radio" name="commissionBase" value="CA" ';
|
||||
if ($conf->global->COMMISSION_BASE == "CA")
|
||||
print '<input type="radio" name="commissionBase" value="TURNOVER" ';
|
||||
if (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "TURNOVER")
|
||||
print 'checked';
|
||||
print ' />';
|
||||
print $langs->trans("CommissionBasedOnCA");
|
||||
print $langs->trans("CommissionBasedOnTurnover");
|
||||
print '<br/>';
|
||||
print '<input type="radio" name="commissionBase" value="MARGES" ';
|
||||
if (!$conf->marges->enabled)
|
||||
print '<input type="radio" name="commissionBase" value="MARGIN" ';
|
||||
if (empty($conf->margin->enabled))
|
||||
print 'disabled';
|
||||
elseif ($conf->global->COMMISSION_BASE == "MARGES")
|
||||
elseif (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "MARGIN")
|
||||
print 'checked';
|
||||
print ' />';
|
||||
print $langs->trans("CommissionBasedOnMargins");
|
||||
@ -141,7 +130,7 @@ $var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("ProductCommissionRate").'</td>';
|
||||
print '<td align="left">';
|
||||
print '<input type="text" name="productCommissionRate" value="'.$conf->global->PRODUCT_COMMISSION_RATE.'" size=6 /> %';
|
||||
print '<input type="text" name="productCommissionRate" value="'.(! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:'').'" size=6 /> %';
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('ProductCommissionRateDetails').'</td>';
|
||||
print '</tr>';
|
||||
@ -151,7 +140,7 @@ $var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$langs->trans("ServiceCommissionRate").'</td>';
|
||||
print '<td align="left">';
|
||||
print '<input type="text" name="serviceCommissionRate" value="'.$conf->global->SERVICE_COMMISSION_RATE.'" size=6 /> %';
|
||||
print '<input type="text" name="serviceCommissionRate" value="'.(! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:'').'" size=6 /> %';
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans('ServiceCommissionRateDetails').'</td>';
|
||||
print '</tr>';
|
||||
@ -169,7 +158,7 @@ print '<br>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.6 $');
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
@ -48,10 +48,12 @@ $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']));
|
||||
$startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']));
|
||||
if (!empty($_POST['enddatemonth']))
|
||||
$enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']));
|
||||
$enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']));
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -90,7 +92,7 @@ else {
|
||||
if (! $sortfield) $sortfield="u.login";
|
||||
}
|
||||
|
||||
// Date d<>but
|
||||
// Start date
|
||||
print '<td>'.$langs->trans('StartDate').'</td>';
|
||||
print '<td width="20%">';
|
||||
$form->select_date($startdate,'startdate','','',1,"sel",1,1);
|
||||
@ -106,22 +108,22 @@ print '</td></tr>';
|
||||
// Include unpayed invoices
|
||||
print '<tr><td>'.$langs->trans("IncludeUnpayedInvoices").'</td><td colspan="4">';
|
||||
print '<input id="selIncluded" type="checkbox" name="unpayed" ';
|
||||
if ($_REQUEST['unpayed'] == 'on')
|
||||
if (GETPOST('unpayed') == 'on')
|
||||
print 'checked ';
|
||||
print '/>';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Total Margin
|
||||
if ($conf->global->COMMISSION_BASE == "MARGES") {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<span id="totalBase"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
if ($conf->global->COMMISSION_BASE == "MARGIN") {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalMargin").'</td><td colspan="4">';
|
||||
print '<span id="totalBase"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
elseif ($conf->global->COMMISSION_BASE == "CA") {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("CATotal").'</td><td colspan="4">';
|
||||
print '<span id="totalBase"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
elseif ($conf->global->COMMISSION_BASE == "TURNOVER") {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("TurnoverTotal").'</td><td colspan="4">';
|
||||
print '<span id="totalBase"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Total Commission
|
||||
@ -135,13 +137,13 @@ print '</form>';
|
||||
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,";
|
||||
$sql.= " u.login,";
|
||||
$sql.= " f.facnumber, f.total as total_ht,";
|
||||
if ($conf->global->COMMISSION_BASE == "MARGES") {
|
||||
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ;
|
||||
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase," ;
|
||||
if ($conf->global->COMMISSION_BASE == "MARGIN") {
|
||||
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ;
|
||||
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase," ;
|
||||
}
|
||||
elseif ($conf->global->COMMISSION_BASE == "CA") {
|
||||
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ;
|
||||
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase," ;
|
||||
elseif ($conf->global->COMMISSION_BASE == "TURNOVER") {
|
||||
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ;
|
||||
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase," ;
|
||||
}
|
||||
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
@ -152,13 +154,13 @@ $sql.= ", ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
||||
$sql.= " AND sc.fk_soc = f.fk_soc";
|
||||
$sql.= " AND sc.fk_user = u.rowid";
|
||||
if ($_REQUEST['unpayed'] == 'on')
|
||||
if (GETPOST('unpayed') == 'on')
|
||||
$sql.= " AND f.fk_statut > 0";
|
||||
else
|
||||
$sql.= " AND f.fk_statut > 1";
|
||||
$sql.= " AND s.entity = ".$conf->entity;
|
||||
$sql.= " AND d.fk_facture = f.rowid";
|
||||
if ($conf->global->COMMISSION_BASE == "MARGES")
|
||||
if ($conf->global->COMMISSION_BASE == "MARGIN")
|
||||
$sql.= " AND d.buy_price_ht IS NOT NULL AND d.buy_price_ht <> 0";
|
||||
if ($agentid > 0)
|
||||
$sql.= " AND sc.fk_user = $agentid";
|
||||
@ -178,37 +180,38 @@ if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
print '<br>';
|
||||
print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,'');
|
||||
print '<br>';
|
||||
print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'');
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if ($agentid > 0)
|
||||
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
|
||||
else
|
||||
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder);
|
||||
else
|
||||
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder);
|
||||
|
||||
// product commission
|
||||
if ($conf->global->COMMISSION_BASE == "MARGES")
|
||||
print_liste_field_titre($langs->trans("ProductMargin"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
elseif ($conf->global->COMMISSION_BASE == "CA")
|
||||
print_liste_field_titre($langs->trans("ProductCA"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
// product commission
|
||||
if ($conf->global->COMMISSION_BASE == "MARGIN")
|
||||
print_liste_field_titre($langs->trans("ProductMargin"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
elseif ($conf->global->COMMISSION_BASE == "TURNOVER")
|
||||
print_liste_field_titre($langs->trans("ProductTurnover"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
|
||||
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
|
||||
// service commission
|
||||
if ($conf->global->COMMISSION_BASE == "MARGES")
|
||||
print_liste_field_titre($langs->trans("ServiceMargin"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
elseif ($conf->global->COMMISSION_BASE == "CA")
|
||||
print_liste_field_titre($langs->trans("ServiceCA"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
// service commission
|
||||
if ($conf->global->COMMISSION_BASE == "MARGIN")
|
||||
print_liste_field_titre($langs->trans("ServiceMargin"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
elseif ($conf->global->COMMISSION_BASE == "TURNOVER")
|
||||
print_liste_field_titre($langs->trans("ServiceTurnover"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
|
||||
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
|
||||
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
// total commission
|
||||
print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
@ -227,32 +230,39 @@ if ($result)
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
if ($agentid > 0) {
|
||||
$companystatic->id=$objp->socid;
|
||||
$companystatic->nom=$objp->nom;
|
||||
$companystatic->client=$objp->client;
|
||||
print "<td>".$companystatic->getNomUrl(1,'customer')."</td>\n";
|
||||
}
|
||||
else {
|
||||
$userstatic->id=$objp->agent;
|
||||
$userstatic->login=$objp->login;
|
||||
print "<td>".$userstatic->getLoginUrl(1)."</td>\n";
|
||||
}
|
||||
// product commission
|
||||
$productCommission = $conf->global->PRODUCT_COMMISSION_RATE * $objp->productBase / 100;
|
||||
print "<td align=\"right\">".price($objp->productBase)."</td>\n";
|
||||
print "<td align=\"right\">".price($conf->global->PRODUCT_COMMISSION_RATE)."</td>\n";
|
||||
$companystatic->id=$objp->socid;
|
||||
$companystatic->nom=$objp->nom;
|
||||
$companystatic->client=$objp->client;
|
||||
print "<td>".$companystatic->getNomUrl(1,'customer')."</td>\n";
|
||||
}
|
||||
else {
|
||||
$userstatic->id=$objp->agent;
|
||||
$userstatic->login=$objp->login;
|
||||
print "<td>".$userstatic->getLoginUrl(1)."</td>\n";
|
||||
}
|
||||
|
||||
// product commission
|
||||
$productCommissionRate=(! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0);
|
||||
$productBase=(! empty($objp->productBase)?$objp->productBase:0);
|
||||
$productCommission = (! empty($productBase)?($productCommissionRate * $productBase / 100):0);
|
||||
print "<td align=\"right\">".price($productBase)."</td>\n";
|
||||
print "<td align=\"right\">".price($productCommissionRate)."</td>\n";
|
||||
print "<td align=\"right\">".price($productCommission)."</td>\n";
|
||||
// service commission
|
||||
$serviceCommission = $conf->global->SERVICE_COMMISSION_RATE * $objp->serviceBase / 100;
|
||||
print "<td align=\"right\">".price($objp->serviceBase)."</td>\n";
|
||||
print "<td align=\"right\">".price($conf->global->SERVICE_COMMISSION_RATE)."</td>\n";
|
||||
|
||||
// service commission
|
||||
$serviceCommissionRate=(! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0);
|
||||
$serviceBase=(! empty($objp->serviceBase)?$objp->serviceBase:0);
|
||||
$serviceCommission = (! empty($serviceBase)?($serviceCommissionRate * $serviceBase / 100):0);
|
||||
print "<td align=\"right\">".price($serviceBase)."</td>\n";
|
||||
print "<td align=\"right\">".price($serviceCommissionRate)."</td>\n";
|
||||
print "<td align=\"right\">".price($serviceCommission)."</td>\n";
|
||||
|
||||
// total commission
|
||||
print "<td align=\"right\">".price($productCommission + $serviceCommission)."</td>\n";
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
$cumul_base_produit += $objp->productBase;
|
||||
$cumul_base_service += $objp->serviceBase;
|
||||
$cumul_base_produit += $productBase;
|
||||
$cumul_base_service += $serviceBase;
|
||||
$cumul_commission_produit += $productCommission;
|
||||
$cumul_commission_service += $serviceCommission;
|
||||
}
|
||||
@ -261,25 +271,25 @@ if ($result)
|
||||
// affichage totaux commission
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||
if ($client)
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
print '<td>';
|
||||
print $langs->trans('TotalCommission')."</td>";
|
||||
// product commission
|
||||
if (! empty($client))
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
print '<td>';
|
||||
print $langs->trans('TotalCommission')."</td>";
|
||||
// product commission
|
||||
print "<td align=\"right\">".price($cumul_base_produit)."</td>\n";
|
||||
print "<td align=\"right\">".price($conf->global->PRODUCT_COMMISSION_RATE)."</td>\n";
|
||||
print "<td align=\"right\">".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."</td>\n";
|
||||
print "<td align=\"right\">".price($cumul_commission_produit)."</td>\n";
|
||||
// service commission
|
||||
// service commission
|
||||
print "<td align=\"right\">".price($cumul_base_service)."</td>\n";
|
||||
print "<td align=\"right\">".price($conf->global->SERVICE_COMMISSION_RATE)."</td>\n";
|
||||
print "<td align=\"right\">".price((! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0))."</td>\n";
|
||||
print "<td align=\"right\">".price($cumul_commission_service)."</td>\n";
|
||||
// total commission
|
||||
print "<td align=\"right\">".price($cumul_commission_produit + $cumul_commission_service)."</td>\n";
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
print "</table>";
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -42,7 +42,7 @@ function commissions_admin_prepare_head()
|
||||
// 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 remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'commissionsadmin');
|
||||
complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@ -2184,7 +2184,7 @@ class Form
|
||||
$more.='<input type="checkbox" class="flat" id="'.$input['name'].'" name="'.$input['name'].'"';
|
||||
if (! is_bool($input['value']) && $input['value'] != 'false') $more.=' checked="checked"';
|
||||
if (is_bool($input['value']) && $input['value']) $more.=' checked="checked"';
|
||||
if ($input['disabled']) $more.=' disabled="disabled"';
|
||||
if (isset($input['disabled'])) $more.=' disabled="disabled"';
|
||||
$more.=' /></td>';
|
||||
$more.='<td valign="top" align="left"> </td>';
|
||||
$more.='</tr>'."\n";
|
||||
@ -3067,11 +3067,11 @@ class Form
|
||||
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg))
|
||||
{
|
||||
// Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS'
|
||||
$syear = $reg[1];
|
||||
$smonth = $reg[2];
|
||||
$sday = $reg[3];
|
||||
$shour = $reg[4];
|
||||
$smin = $reg[5];
|
||||
$syear = (! empty($reg[1])?$reg[1]:'');
|
||||
$smonth = (! empty($reg[2])?$reg[2]:'');
|
||||
$sday = (! empty($reg[3])?$reg[3]:'');
|
||||
$shour = (! empty($reg[4])?$reg[4]:'');
|
||||
$smin = (! empty($reg[5])?$reg[5]:'');
|
||||
}
|
||||
elseif (strval($set_time) != '' && $set_time != -1)
|
||||
{
|
||||
|
||||
@ -67,7 +67,7 @@ class modCommissions extends DolibarrModules
|
||||
$this->dirs = array();
|
||||
|
||||
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
|
||||
$this->config_page_url = array("commissions.php");
|
||||
$this->config_page_url = array("commissions.php@commissions");
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array("modFacture", "modMargin"); // List of modules id that must be enabled if this module is enabled
|
||||
@ -77,7 +77,7 @@ class modCommissions extends DolibarrModules
|
||||
$this->langfiles = array("commissions");
|
||||
|
||||
// Constants
|
||||
$this->const = array(); // List of particular constants to add when module is enabled
|
||||
$this->const = array(0=>array('COMMISSION_BASE',"chaine","TURNOVER",'Default commission base',0)); // List of particular constants to add when module is enabled
|
||||
|
||||
// New pages on tabs
|
||||
$this->tabs = array();
|
||||
@ -106,15 +106,15 @@ class modCommissions extends DolibarrModules
|
||||
|
||||
// left menu entry
|
||||
$this->menu[$r]=array(
|
||||
'fk_menu'=>0, // Put 0 if this is a top menu
|
||||
'type'=>'top', // This is a Top menu entry
|
||||
'fk_menu'=>'fk_mainmenu=accountancy', // Put 0 if this is a top menu
|
||||
'type'=>'left', // This is a Top menu entry
|
||||
'titre'=>'Commissions',
|
||||
'mainmenu'=>'commissions',
|
||||
'leftmenu'=>'0', // 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).
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'commissions', // 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'=>'/commissions/index.php',
|
||||
'langs'=>'commissions@commissions', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>110,
|
||||
'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled.
|
||||
'langs'=>'commissions', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'position'=>200,
|
||||
'enabled'=>'$conf->commissions->enabled', // 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
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
|
||||
@ -59,13 +59,13 @@ class modMargin extends DolibarrModules
|
||||
$this->special = 0;
|
||||
// Name of png file (without png) used for this module.
|
||||
// Png file must be in theme/yourtheme/img directory under name object_pictovalue.png.
|
||||
$this->picto='marges';
|
||||
$this->picto='margin';
|
||||
|
||||
// Data directories to create when module is enabled.
|
||||
$this->dirs = array('/margin/temp');
|
||||
|
||||
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
|
||||
$this->config_page_url = array("margin.php");
|
||||
$this->config_page_url = array("margin.php@margin");
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array("modPropale", "modProduct"); // List of modules id that must be enabled if this module is enabled
|
||||
@ -98,62 +98,19 @@ class modMargin extends DolibarrModules
|
||||
|
||||
// left menu entry
|
||||
$this->menu[$r]=array(
|
||||
'fk_menu'=>0, // Put 0 if this is a top menu
|
||||
'type'=>'top', // This is a Top menu entry
|
||||
'fk_menu'=>'fk_mainmenu=accountancy', // Put 0 if this is a top menu
|
||||
'type'=>'left', // This is a Top menu entry
|
||||
'titre'=>'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).
|
||||
'mainmenu'=>'accountancy',
|
||||
'leftmenu'=>'margins', // 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'=>'/margin/index.php',
|
||||
'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'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'=>'$conf->margin->enabled', // 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
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
|
||||
$r++;
|
||||
|
||||
// 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
|
||||
'titre'=>'ProductMargins',
|
||||
'mainmenu'=>'margins',
|
||||
'url'=>'/margin/productMargins.php',
|
||||
'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'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.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users,1=external users, 2=both
|
||||
$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)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'CustomerMargins',
|
||||
'mainmenu'=>'margins',
|
||||
'url'=>'/margin/customerMargins.php',
|
||||
'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'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.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users,1=external users, 2=both
|
||||
$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)
|
||||
'type'=>'left', // This is a Left menu entry
|
||||
'titre'=>'AgentMargins',
|
||||
'mainmenu'=>'margins',
|
||||
'url'=>'/margin/agentMargins.php',
|
||||
'langs'=>'margins', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
|
||||
'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.
|
||||
'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->level1->level2' if you want your menu with a permission rules
|
||||
'target'=>'',
|
||||
'user'=>2); // 0=Menu for internal users,1=external users, 2=both
|
||||
$r++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -781,9 +781,9 @@ if ($action == 'create')
|
||||
if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||
{
|
||||
// Show warehouse combo list
|
||||
$ent = "entl".$indiceAsked;
|
||||
$idl = "idl".$indiceAsked;
|
||||
$tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int');
|
||||
$ent = "entl".$indiceAsked;
|
||||
$idl = "idl".$indiceAsked;
|
||||
$tmpentrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int');
|
||||
print $formproduct->selectWarehouses($tmpentrepot_id,'entl'.$indiceAsked,'',1,0,$line->fk_product);
|
||||
if ($tmpentrepot_id && $tmpentrepot_id == GETPOST('entrepot_id','int'))
|
||||
{
|
||||
|
||||
@ -77,7 +77,7 @@ if (! $result && ! empty($_SERVER["GATEWAY_INTERFACE"])) // If install not do
|
||||
|
||||
// Force PHP error_reporting setup (Dolibarr may report warning without this)
|
||||
if (! empty($dolibarr_strict_mode))
|
||||
{
|
||||
{
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
}
|
||||
else
|
||||
|
||||
@ -117,30 +117,30 @@ function checkLinkedElements($sourcetype, $targettype)
|
||||
function clean_data_ecm_directories()
|
||||
{
|
||||
global $db, $langs;
|
||||
|
||||
// Clean data from ecm_directories
|
||||
$sql="SELECT rowid, label FROM ".MAIN_DB_PREFIX."ecm_directories";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while($obj=$db->fetch_object($resql))
|
||||
{
|
||||
$id=$obj->rowid;
|
||||
$label=$obj->label;
|
||||
$newlabel=dol_sanitizeFileName($label);
|
||||
if ($label != $newlabel)
|
||||
{
|
||||
$sqlupdate="UPDATE ".MAIN_DB_PREFIX."ecm_directories set label='".$newlabel."' WHERE rowid=".$id;
|
||||
print '<tr><td>'.$sqlupdate."</td></tr>\n";
|
||||
$resqlupdate=$db->query($sqlupdate);
|
||||
if (! $resqlupdate) dol_print_error($db,'Failed to update');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else dol_print_error($db,'Failed to run request');
|
||||
|
||||
return;
|
||||
// Clean data from ecm_directories
|
||||
$sql="SELECT rowid, label FROM ".MAIN_DB_PREFIX."ecm_directories";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while($obj=$db->fetch_object($resql))
|
||||
{
|
||||
$id=$obj->rowid;
|
||||
$label=$obj->label;
|
||||
$newlabel=dol_sanitizeFileName($label);
|
||||
if ($label != $newlabel)
|
||||
{
|
||||
$sqlupdate="UPDATE ".MAIN_DB_PREFIX."ecm_directories set label='".$newlabel."' WHERE rowid=".$id;
|
||||
print '<tr><td>'.$sqlupdate."</td></tr>\n";
|
||||
$resqlupdate=$db->query($sqlupdate);
|
||||
if (! $resqlupdate) dol_print_error($db,'Failed to update');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else dol_print_error($db,'Failed to run request');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -23,14 +23,14 @@ ProductCommission=Commission / produits
|
||||
ServiceCommission=Commission / services
|
||||
|
||||
CommissionBase=Base de calcul des commissions
|
||||
CommissionBasedOnCA=Commissions calculées sur le CA
|
||||
CommissionBasedOnTurnover=Commissions calculées sur le CA
|
||||
CommissionBasedOnMargins=Commissions calculées sur les marges
|
||||
CommissionBaseDetails=Définit le mode de calcul des commissions
|
||||
CommissionBasedOnMarginsDetails=Le calcul basé sur les marges nécessite l'activation du module marges.
|
||||
|
||||
CATotal = Chiffre d'affaire réalisé HT
|
||||
ProductCA=CA HT / produits
|
||||
ServiceCA=CA HT / services
|
||||
TurnoverTotal = Chiffre d'affaire réalisé HT
|
||||
ProductTurnover=CA HT / produits
|
||||
ServiceTurnover=CA HT / services
|
||||
|
||||
CommercialAgent=Agent commercial
|
||||
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file /htdocs/admin/margin.php
|
||||
* \file /htdocs/margin/admin/margin.php
|
||||
* \ingroup margin
|
||||
* \brief Page to setup margin module
|
||||
*/
|
||||
|
||||
include("../main.inc.php");
|
||||
include("../../main.inc.php");
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/margin/lib/margins.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
||||
@ -121,7 +121,7 @@ $form = new Form($db);
|
||||
|
||||
// GLOBAL DISCOUNT MANAGEMENT
|
||||
$var=!$var;
|
||||
print "<form method=\"post\" action=\"marges.php\">";
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"typemarges\">";
|
||||
print '<tr '.$bc[$var].'>';
|
||||
@ -219,7 +219,7 @@ print '</tr>';
|
||||
|
||||
// GLOBAL DISCOUNT MANAGEMENT
|
||||
$var=!$var;
|
||||
print "<form method=\"post\" action=\"marges.php\">";
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print "<input type=\"hidden\" name=\"action\" value=\"remises\">";
|
||||
print '<tr '.$bc[$var].'>';
|
||||
@ -39,12 +39,16 @@ $mesg = '';
|
||||
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="s.nom";
|
||||
$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']))
|
||||
@ -68,30 +72,16 @@ print_fiche_titre($text);
|
||||
// Show tabs
|
||||
$head=marges_prepare_head($user);
|
||||
$titre=$langs->trans("Margins");
|
||||
$picto='marges';
|
||||
$picto='margin';
|
||||
dol_fiche_head($head, 'agentMargins', $titre, 0, $picto);
|
||||
|
||||
print '<form method="post" name="sel">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
if ($agentid > 0) {
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_dolusers($selected=$agentid,$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly='');
|
||||
print '</td></tr>';
|
||||
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="s.nom";
|
||||
}
|
||||
else {
|
||||
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_dolusers($selected='',$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly='');
|
||||
print '</td></tr>';
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="u.login";
|
||||
}
|
||||
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_dolusers($agentid,'agentid',1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Start date
|
||||
print '<td>'.$langs->trans('StartDate').'</td>';
|
||||
@ -112,14 +102,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
|
||||
print '<span id="marginRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Mark Rate
|
||||
if ($conf->global->DISPLAY_MARK_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
|
||||
print '<span id="markRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
@ -163,24 +153,25 @@ if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
print '<br>';
|
||||
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,'');
|
||||
print '<br>';
|
||||
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,'');
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if ($agentid > 0)
|
||||
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
|
||||
else
|
||||
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder);
|
||||
else
|
||||
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder);
|
||||
|
||||
print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buyng_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Margin"),$_SERVER["PHP_SELF"],"marge","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print_liste_field_titre($langs->trans("MarginRate"),$_SERVER["PHP_SELF"],"d.marge_tx","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"d.marque_tx","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
$cumul_achat = 0;
|
||||
@ -188,34 +179,34 @@ if ($result)
|
||||
$cumul_qty = 0;
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
$var=true;
|
||||
while ($i < $num && $i < $conf->liste_limit)
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'' ;
|
||||
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'' ;
|
||||
$marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price ,5)):'';
|
||||
$markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price ,5)):'';
|
||||
|
||||
$var=!$var;
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
if ($agentid > 0) {
|
||||
$companystatic->id=$objp->socid;
|
||||
$companystatic->nom=$objp->nom;
|
||||
$companystatic->client=$objp->client;
|
||||
print "<td>".$companystatic->getNomUrl(1,'customer')."</td>\n";
|
||||
}
|
||||
else {
|
||||
$userstatic->id=$objp->agent;
|
||||
$userstatic->login=$objp->login;
|
||||
print "<td>".$userstatic->getLoginUrl(1)."</td>\n";
|
||||
}
|
||||
$companystatic->id=$objp->socid;
|
||||
$companystatic->nom=$objp->nom;
|
||||
$companystatic->client=$objp->client;
|
||||
print "<td>".$companystatic->getNomUrl(1,'customer')."</td>\n";
|
||||
}
|
||||
else {
|
||||
$userstatic->id=$objp->agent;
|
||||
$userstatic->login=$objp->login;
|
||||
print "<td>".$userstatic->getLoginUrl(1)."</td>\n";
|
||||
}
|
||||
print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
@ -227,24 +218,24 @@ if ($result)
|
||||
// affichage totaux marges
|
||||
$var=!$var;
|
||||
$totalMargin = $cumul_vente - $cumul_achat;
|
||||
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'' ;
|
||||
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ;
|
||||
$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'';
|
||||
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'';
|
||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||
if ($client)
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
print '<td>';
|
||||
print $langs->trans('TotalMargin')."</td>";
|
||||
if (! empty($client))
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
print '<td>';
|
||||
print $langs->trans('TotalMargin')."</td>";
|
||||
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
|
||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
print "</table>";
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -42,12 +42,16 @@ $mesg = '';
|
||||
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="s.nom";
|
||||
$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']))
|
||||
@ -70,37 +74,35 @@ print_fiche_titre($text);
|
||||
// Show tabs
|
||||
$head=marges_prepare_head($user);
|
||||
$titre=$langs->trans("Margins");
|
||||
$picto='marges';
|
||||
$picto='margin';
|
||||
dol_fiche_head($head, 'customerMargins', $titre, 0, $picto);
|
||||
|
||||
print '<form method="post" name="sel">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$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 '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>';
|
||||
print '<td colspan="4">';
|
||||
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1);
|
||||
print '</td></tr>';
|
||||
if ($soc->client)
|
||||
{
|
||||
print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>';
|
||||
print '<td colspan="4">';
|
||||
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1',1,0,1);
|
||||
print '</td></tr>';
|
||||
|
||||
$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 '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>';
|
||||
print '<td colspan="4">';
|
||||
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1);
|
||||
print '</td></tr>';
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="s.nom";
|
||||
else {
|
||||
print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>';
|
||||
print '<td colspan="4">';
|
||||
$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid','client=1',1,0,1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Start date
|
||||
@ -122,14 +124,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
|
||||
print '<span id="marginRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Mark Rate
|
||||
if ($conf->global->DISPLAY_MARK_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
|
||||
print '<span id="markRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
@ -169,25 +171,25 @@ if ($result)
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
print '<br>';
|
||||
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 "<table class=\"noborder\" width=\"100%\">";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\n";
|
||||
|
||||
$cumul_achat = 0;
|
||||
@ -224,9 +226,9 @@ if ($result)
|
||||
print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
@ -249,9 +251,9 @@ if ($result)
|
||||
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
|
||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
@ -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++;
|
||||
|
||||
@ -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 '<form method="post" name="sel">';
|
||||
@ -84,12 +88,9 @@ print '<table class="border" width="100%">';
|
||||
|
||||
if ($id > 0) {
|
||||
|
||||
$societe = new Societe($db, $socid);
|
||||
$societe->fetch($socid);
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans('ChooseProduct/Service').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_produits($selected=$id, $htmlname='id', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=1);
|
||||
print $form->select_produits($id,'id','',20,0,1,2,'',1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans('AllProducts').'</td>';
|
||||
@ -99,12 +100,11 @@ if ($id > 0) {
|
||||
if (! $sortfield) $sortfield="f.datef";
|
||||
}
|
||||
else {
|
||||
print '<tr><td width="20%">'.$langs->trans('ChooseProduct/Service').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_produits($selected='', $htmlname='id', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=1);
|
||||
print '</td></tr>';
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
if (! $sortfield) $sortfield="p.ref";
|
||||
print '<tr><td width="20%">'.$langs->trans('ChooseProduct/Service').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_produits('','id','',20,0,1,2,'',1);
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
|
||||
// Start date
|
||||
@ -126,14 +126,14 @@ print '<span id="totalMargin"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="4">';
|
||||
print '<span id="marginRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Mark Rate
|
||||
if ($conf->global->DISPLAY_MARK_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="4">';
|
||||
print '<span id="markRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
@ -142,7 +142,7 @@ if ($conf->global->DISPLAY_MARK_RATES) {
|
||||
print "</table>";
|
||||
print '</form>';
|
||||
|
||||
$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 '<br>';
|
||||
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,'');
|
||||
print '<br>';
|
||||
print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,0,'');
|
||||
|
||||
$i = 0;
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\n";
|
||||
|
||||
$cumul_achat = 0;
|
||||
@ -213,29 +213,29 @@ if ($result)
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
if ($id > 0) {
|
||||
print '<td>';
|
||||
$invoicestatic->id=$objp->facid;
|
||||
$invoicestatic->ref=$objp->facnumber;
|
||||
print $invoicestatic->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
print "<td align=\"center\">";
|
||||
print dol_print_date($db->jdate($objp->datef),'day')."</td>";
|
||||
}
|
||||
else {
|
||||
print '<td>';
|
||||
$invoicestatic->id=$objp->facid;
|
||||
$invoicestatic->ref=$objp->facnumber;
|
||||
print $invoicestatic->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
print "<td align=\"center\">";
|
||||
print dol_print_date($db->jdate($objp->datef),'day')."</td>";
|
||||
}
|
||||
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 "<td>".$product_static->getNomUrl(1)."</td>\n";
|
||||
}
|
||||
print "<td>".$product_static->getNomUrl(1)."</td>\n";
|
||||
}
|
||||
print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
@ -251,20 +251,20 @@ if ($result)
|
||||
$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ;
|
||||
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
|
||||
if ($id > 0)
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
print '<td>';
|
||||
print $langs->trans('TotalMargin')."</td>";
|
||||
print '<td colspan=2>';
|
||||
else
|
||||
print '<td>';
|
||||
print $langs->trans('TotalMargin')."</td>";
|
||||
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
|
||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
print "</table>";
|
||||
print "</table>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -287,9 +287,9 @@ $(document).ready(function() {
|
||||
$("div.fiche form").submit();
|
||||
});
|
||||
|
||||
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
||||
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate)."%"); ?>");
|
||||
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
|
||||
$("#totalMargin").html("<?php echo price($totalMargin); ?>");
|
||||
$("#marginRate").html("<?php echo (($marginRate === '')?'n/a':price($marginRate)."%"); ?>");
|
||||
$("#markRate").html("<?php echo (($markRate === '')?'n/a':price($markRate)."%"); ?>");
|
||||
|
||||
});
|
||||
</script>
|
||||
@ -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 '<table class="border" width="100%">';
|
||||
|
||||
@ -111,14 +111,14 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="3">';
|
||||
print '<span id="marginRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Mark Rate
|
||||
if ($conf->global->DISPLAY_MARK_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="3">';
|
||||
print '<span id="markRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
@ -128,7 +128,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</div>';
|
||||
|
||||
|
||||
$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 "<table class=\"noborder\" width=\"100%\">";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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 "</tr>\n";
|
||||
|
||||
$cumul_achat = 0;
|
||||
@ -200,9 +200,9 @@ if ($id > 0 || ! empty($ref))
|
||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->qty)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
|
||||
print "</tr>\n";
|
||||
@ -224,9 +224,9 @@ if ($id > 0 || ! empty($ref))
|
||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||
print "<td align=\"right\">".price($cumul_qty)."</td>\n";
|
||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print '<td align="right"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
@ -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 '<table class="border" width="100%">';
|
||||
|
||||
@ -109,14 +109,14 @@ if ($socid > 0)
|
||||
print '</td></tr>';
|
||||
|
||||
// Margin Rate
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarginRate").'</td><td colspan="3">';
|
||||
print '<span id="marginRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Mark Rate
|
||||
if ($conf->global->DISPLAY_MARK_RATES) {
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
|
||||
print '<tr style="font-weight: bold"><td>'.$langs->trans("MarkRate").'</td><td colspan="3">';
|
||||
print '<span id="markRate"></span>'; // set by jquery (see below)
|
||||
print '</td></tr>';
|
||||
@ -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 "</tr>\n";
|
||||
@ -191,9 +191,9 @@ if ($socid > 0)
|
||||
print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
|
||||
print "<td align=\"right\">".price($objp->marge)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
|
||||
print "</tr>\n";
|
||||
@ -213,9 +213,9 @@ if ($socid > 0)
|
||||
print "<td align=\"right\">".price($cumul_vente)."</td>\n";
|
||||
print "<td align=\"right\">".price($cumul_achat)."</td>\n";
|
||||
print "<td align=\"right\">".price($totalMargin)."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARGIN_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
|
||||
if ($conf->global->DISPLAY_MARK_RATES)
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
|
||||
print '<td align="right"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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;
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 579 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 579 B |
@ -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;
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 579 B |
@ -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;
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 579 B |
@ -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;
|
||||
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 579 B |
@ -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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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))
|
||||
|
||||