diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index e0eb74f6aca..8c39f3a8fe7 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -200,7 +200,7 @@ print $langs->trans("TotalNumberOfActivatedModules",($nbofactivatedmodules-1)); if ($nbofactivatedmodules <= 1) print ' '.img_warning($langs->trans("YouMustEnableOneModule")); print '
'."\n"; -print "
\n"; +print "
\n"; $h = 0; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 7f070c07df5..f39c64d872d 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -928,7 +928,7 @@ else print '

'; } - 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') diff --git a/htdocs/admin/commissions.php b/htdocs/commissions/admin/commissions.php similarity index 65% rename from htdocs/admin/commissions.php rename to htdocs/commissions/admin/commissions.php index 64e618633ac..a48f6ead1ca 100644 --- a/htdocs/admin/commissions.php +++ b/htdocs/commissions/admin/commissions.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012 Christophe Battarel * * 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 . */ /** @@ -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=''.$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 '
'; -// COMMISSION BASE (CA / MARGES) +// COMMISSION BASE (TURNOVER / MARGIN) $var=!$var; print ''; print ''.$langs->trans("CommissionBase").''; print ''; -print 'global->COMMISSION_BASE == "CA") +print 'global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "TURNOVER") print 'checked'; print ' />'; -print $langs->trans("CommissionBasedOnCA"); +print $langs->trans("CommissionBasedOnTurnover"); print '
'; -print 'marges->enabled) +print '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 ''; print ''.$langs->trans("ProductCommissionRate").''; print ''; -print '  %'; +print '  %'; print ''; print ''.$langs->trans('ProductCommissionRateDetails').''; print ''; @@ -151,7 +140,7 @@ $var=!$var; print ''; print ''.$langs->trans("ServiceCommissionRate").''; print ''; -print '  %'; +print '  %'; print ''; print ''.$langs->trans('ServiceCommissionRateDetails').''; print ''; @@ -169,7 +158,7 @@ print '
'; print '
'; -$db->close(); -llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.6 $'); +llxFooter(); +$db->close(); ?> diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php index 65e2ad70b21..c6988f19b8d 100644 --- a/htdocs/commissions/index.php +++ b/htdocs/commissions/index.php @@ -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 ''.$langs->trans('StartDate').''; print ''; $form->select_date($startdate,'startdate','','',1,"sel",1,1); @@ -106,22 +108,22 @@ print ''; // Include unpayed invoices print ''.$langs->trans("IncludeUnpayedInvoices").''; print ''; print ''; // Total Margin -if ($conf->global->COMMISSION_BASE == "MARGES") { - print ''.$langs->trans("TotalMargin").''; - print ''; // set by jquery (see below) - print ''; +if ($conf->global->COMMISSION_BASE == "MARGIN") { + print ''.$langs->trans("TotalMargin").''; + print ''; // set by jquery (see below) + print ''; } -elseif ($conf->global->COMMISSION_BASE == "CA") { - print ''.$langs->trans("CATotal").''; - print ''; // set by jquery (see below) - print ''; +elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { + print ''.$langs->trans("TurnoverTotal").''; + print ''; // set by jquery (see below) + print ''; } // Total Commission @@ -135,13 +137,13 @@ print ''; $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 '
'; - print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,''); + print '
'; + print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); $i = 0; print ""; print ''; 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 "\n"; @@ -227,32 +230,39 @@ if ($result) print ""; if ($agentid > 0) { - $companystatic->id=$objp->socid; - $companystatic->nom=$objp->nom; - $companystatic->client=$objp->client; - print "\n"; - } - else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "\n"; - } - // product commission - $productCommission = $conf->global->PRODUCT_COMMISSION_RATE * $objp->productBase / 100; - print "\n"; - print "\n"; + $companystatic->id=$objp->socid; + $companystatic->nom=$objp->nom; + $companystatic->client=$objp->client; + print "\n"; + } + else { + $userstatic->id=$objp->agent; + $userstatic->login=$objp->login; + print "\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 "\n"; + print "\n"; print "\n"; - // service commission - $serviceCommission = $conf->global->SERVICE_COMMISSION_RATE * $objp->serviceBase / 100; - print "\n"; - print "\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 "\n"; + print "\n"; print "\n"; + // total commission print "\n"; print "\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 ''; - if ($client) - print '"; - // product commission + if (! empty($client)) + print '"; + // product commission print "\n"; - print "\n"; + print "\n"; print "\n"; - // service commission + // service commission print "\n"; - print "\n"; + print "\n"; print "\n"; // total commission print "\n"; print "\n"; - print "
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($objp->productBase)."".price($conf->global->PRODUCT_COMMISSION_RATE)."".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($productBase)."".price($productCommissionRate)."".price($productCommission)."".price($objp->serviceBase)."".price($conf->global->SERVICE_COMMISSION_RATE)."".price($serviceBase)."".price($serviceCommissionRate)."".price($serviceCommission)."".price($productCommission + $serviceCommission)."
'; - else - print ''; - print $langs->trans('TotalCommission')."'; + else + print ''; + print $langs->trans('TotalCommission')."".price($cumul_base_produit)."".price($conf->global->PRODUCT_COMMISSION_RATE)."".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."".price($cumul_commission_produit)."".price($cumul_base_service)."".price($conf->global->SERVICE_COMMISSION_RATE)."".price((! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0))."".price($cumul_commission_service)."".price($cumul_commission_produit + $cumul_commission_service)."
"; + print ""; } else { diff --git a/htdocs/commissions/lib/commissions.lib.php b/htdocs/commissions/lib/commissions.lib.php index ca71d41536c..89fba20a60c 100644 --- a/htdocs/commissions/lib/commissions.lib.php +++ b/htdocs/commissions/lib/commissions.lib.php @@ -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; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f94797cb679..b1c7383e32c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2184,7 +2184,7 @@ class Form $more.='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 diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index a14068f348e..f94193393fc 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -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++; } /** diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index efa3d132d24..fc8c2ed7855 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -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')) { diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index ffa61de2c9c..f0471874ea4 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -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 diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php index 05b06fda034..f7839e5dc49 100644 --- a/htdocs/install/lib/repair.lib.php +++ b/htdocs/install/lib/repair.lib.php @@ -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 ''.$sqlupdate."\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 ''.$sqlupdate."\n"; + $resqlupdate=$db->query($sqlupdate); + if (! $resqlupdate) dol_print_error($db,'Failed to update'); + } + + } + } + else dol_print_error($db,'Failed to run request'); + + return; } ?> diff --git a/htdocs/langs/fr_FR/commissions.lang b/htdocs/langs/fr_FR/commissions.lang index 350b12a8099..97dd17d9cba 100644 --- a/htdocs/langs/fr_FR/commissions.lang +++ b/htdocs/langs/fr_FR/commissions.lang @@ -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 diff --git a/htdocs/admin/margin.php b/htdocs/margin/admin/margin.php similarity index 97% rename from htdocs/admin/margin.php rename to htdocs/margin/admin/margin.php index 782d4df55e0..1396c8c13a0 100644 --- a/htdocs/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -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 "
"; +print ''; print ''; print ""; print ''; @@ -219,7 +219,7 @@ print ''; // GLOBAL DISCOUNT MANAGEMENT $var=!$var; -print ""; +print ''; print ''; print ""; print ''; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index f11db0f42f4..51327212ba7 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -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 ''; print ''; -if ($agentid > 0) { - - print ''; - print ''; - - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="s.nom"; -} -else { - print ''; - print ''; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="u.login"; -} +print ''; +print ''; // Start date print ''; @@ -112,14 +102,14 @@ print ''; // set by jquery (see below) print ''; // Margin Rate -if ($conf->global->DISPLAY_MARGIN_RATES) { +if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate -if ($conf->global->DISPLAY_MARK_RATES) { +if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ''; @@ -163,24 +153,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 '
'; + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); $i = 0; print "
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers($selected=$agentid,$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly=''); - print '
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers($selected='',$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly=''); - print '
'.$langs->trans('CommercialAgent').''; +print $form->select_dolusers($agentid,'agentid',1); +print '
'.$langs->trans('StartDate').'
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
"; print ''; 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 "\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 ""; if ($agentid > 0) { - $companystatic->id=$objp->socid; - $companystatic->nom=$objp->nom; - $companystatic->client=$objp->client; - print "\n"; - } - else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "\n"; - } + $companystatic->id=$objp->socid; + $companystatic->nom=$objp->nom; + $companystatic->client=$objp->client; + print "\n"; + } + else { + $userstatic->id=$objp->agent; + $userstatic->login=$objp->login; + print "\n"; + } print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\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 ''; - if ($client) - print '"; + if (! empty($client)) + print '"; print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; - print "
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
'; - else - print ''; - print $langs->trans('TotalMargin')."'; + else + print ''; + print $langs->trans('TotalMargin')."".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
"; + print ""; } else { diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 979e67b6345..27c1e230a2f 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -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 ''; print ''; -$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 ''; - print ''; + if ($soc->client) + { + print ''; + 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 ''; - print ''; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="s.nom"; +else { + print ''; + 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 ''; } // Mark Rate -if ($conf->global->DISPLAY_MARK_RATES) { +if (! empty($conf->global->DISPLAY_MARK_RATES)) { 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 "
'.$langs->trans('ThirdPartyName').''; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1); - print '
'.$langs->trans('ThirdPartyName').''; + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1',1,0,1); + print '
'.$langs->trans('ThirdPartyName').''; - $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid', $filter='client=1',$showempty=1, $showtype=0, $forcecombo=1); - print '
'.$langs->trans('ThirdPartyName').''; + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,null,'socid','client=1',1,0,1); + print '
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) 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 "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; $i++; @@ -249,9 +251,9 @@ if ($result) print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\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 ''; @@ -84,12 +88,9 @@ print '
".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
'; if ($id > 0) { - $societe = new Societe($db, $socid); - $societe->fetch($socid); - print ''; print ''; print ''; @@ -99,12 +100,11 @@ if ($id > 0) { if (! $sortfield) $sortfield="f.datef"; } else { - print ''; - print ''; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="p.ref"; + print ''; + print ''; + } // Start date @@ -126,14 +126,14 @@ print ''; // set by jquery (see below) print ''; // Margin Rate -if ($conf->global->DISPLAY_MARGIN_RATES) { +if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate -if ($conf->global->DISPLAY_MARK_RATES) { +if (! empty($conf->global->DISPLAY_MARK_RATES)) { print ''; @@ -142,7 +142,7 @@ if ($conf->global->DISPLAY_MARK_RATES) { print "
'.$langs->trans('ChooseProduct/Service').''; - 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 '
'.$langs->trans('AllProducts').'
'.$langs->trans('ChooseProduct/Service').''; - print $form->select_produits($selected='', $htmlname='id', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=1); - print '
'.$langs->trans('ChooseProduct/Service').''; + print $form->select_produits('','id','',20,0,1,2,'',1); + print '
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
"; 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 '\n"; - print ""; - } - else { + print '\n"; + print ""; + } + 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 "\n"; - } + print "\n"; + } print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\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 '"; + print '"; print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print "\n"; - print "
'; - $invoicestatic->id=$objp->facid; - $invoicestatic->ref=$objp->facnumber; - print $invoicestatic->getNomUrl(1); - print ""; - print dol_print_date($db->jdate($objp->datef),'day')."'; + $invoicestatic->id=$objp->facid; + $invoicestatic->ref=$objp->facnumber; + print $invoicestatic->getNomUrl(1); + print ""; + print dol_print_date($db->jdate($objp->datef),'day')."".$product_static->getNomUrl(1)."".$product_static->getNomUrl(1)."".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
'; - else - print ''; - print $langs->trans('TotalMargin')."'; + else + print ''; + print $langs->trans('TotalMargin')."".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."
"; + 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 ''; } // Mark Rate - if ($conf->global->DISPLAY_MARK_RATES) { + if (! empty($conf->global->DISPLAY_MARK_RATES)) { 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 "
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) 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 "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print ''; print "\n"; @@ -224,9 +224,9 @@ if ($id > 0 || ! empty($ref)) print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\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 '
".price($objp->buying_price)."".price($objp->qty)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
".price($cumul_achat)."".price($cumul_qty)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")." 
'; @@ -109,14 +109,14 @@ if ($socid > 0) print ''; // Margin Rate - if ($conf->global->DISPLAY_MARGIN_RATES) { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''; } // Mark Rate - if ($conf->global->DISPLAY_MARK_RATES) { + if (! empty($conf->global->DISPLAY_MARK_RATES)) { 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 "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\n"; print ''; print "\n"; @@ -213,9 +213,9 @@ if ($socid > 0) print "\n"; print "\n"; print "\n"; - if ($conf->global->DISPLAY_MARGIN_RATES) + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print "\n"; - if ($conf->global->DISPLAY_MARK_RATES) + if (! empty($conf->global->DISPLAY_MARK_RATES)) print "\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))
'.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print '
'.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print '
".price($objp->selling_price)."".price($objp->buying_price)."".price($objp->marge)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'
".price($cumul_vente)."".price($cumul_achat)."".price($totalMargin)."".(($marginRate === '')?'n/a':price($marginRate)."%")."".(($markRate === '')?'n/a':price($markRate)."%")."