From 54f963f8ae5ca2999396421b38968f34dcd10383 Mon Sep 17 00:00:00 2001 From: simnandez Date: Sat, 16 Mar 2013 22:32:03 +0100 Subject: [PATCH 1/5] Trad: Fix: A better fix for status/list of orders. There was a confusion because of bad translation key StatusOrderToBill that in fact mean "StatusOrderDelivered". --- htdocs/langs/ca_ES/orders.lang | 4 ++-- htdocs/langs/es_ES/orders.lang | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/ca_ES/orders.lang b/htdocs/langs/ca_ES/orders.lang index 39ee41a4ca9..a0a49bb243c 100644 --- a/htdocs/langs/ca_ES/orders.lang +++ b/htdocs/langs/ca_ES/orders.lang @@ -84,8 +84,8 @@ NumberOfOrdersByMonth=Nombre de comandes per mes AmountOfOrdersByMonthHT=Import total de comandes per mes (Sense IVA) ListOfOrders=Llistat de comandes CloseOrder=Tancar comanda -ConfirmCloseOrder=Esteu segur de voler tancar aquesta comanda? Un cop tancat, haurà de facturar-se -ConfirmCloseOrderIfSending=Esteu segur de voler tancar aquesta comanda? No ha de tancar una comanda que encara no té els seus productes enviats +ConfirmCloseOrder=Esteu segur que voleu classificar aquesta comanda com a enviat? Un cop enviat una comanda, només podrà facturar-se +ConfirmCloseOrderIfSending=Esteu segur que voleu tancar aquesta comanda? Només hauria de tancar una comanda quan aquesta hagi estat enviada completament. ConfirmDeleteOrder=Esteu segur de voler eliminar aquest comanda? ConfirmValidateOrder=Esteu segur de voler validar aquesta comanda sota la referència %s ? ConfirmUnvalidateOrder=Esteu segur de voler restaurar la comanda %s a l'estat esborrany? diff --git a/htdocs/langs/es_ES/orders.lang b/htdocs/langs/es_ES/orders.lang index 65044ab09a7..3b1069cf7a6 100644 --- a/htdocs/langs/es_ES/orders.lang +++ b/htdocs/langs/es_ES/orders.lang @@ -84,8 +84,8 @@ NumberOfOrdersByMonth=Número de pedidos por mes AmountOfOrdersByMonthHT=Importe total de pedidos por mes (sin IVA) ListOfOrders=Listado de pedidos CloseOrder=Cerrar pedido -ConfirmCloseOrder=¿Está seguro de querer cerrar este pedido? Una vez cerrado, deberá facturarse -ConfirmCloseOrderIfSending=¿Está seguro de querer cerrar este pedido? No debe cerrar un pedido que aún no tiene sus productos enviados +ConfirmCloseOrder=¿Está seguro de querer clasificar este pedido como enviado? Una vez enviado un pedido, solo podrá facturarse +ConfirmCloseOrderIfSending=¿Está seguro de querer cerrar este pedido? Solamente debería cerrar un pedido cuando este haya sido enviado completamente. ConfirmDeleteOrder=¿Está seguro de querer eliminar este pedido? ConfirmValidateOrder=¿Está seguro de querer validar este pedido bajo la referencia %s ? ConfirmUnvalidateOrder=¿Está seguro de querer restaurar el pedido %s al estado borrador? From e59084cafcb861c2aa80cd796c67f898c62f1ca6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 18 Mar 2013 13:04:08 +0100 Subject: [PATCH 2/5] various fixes on margin : - fix on sortorder - fix for credit notes - fix for total --- htdocs/margin/agentMargins.php | 35 +++++++++++++--------- htdocs/margin/customerMargins.php | 37 +++++++++++++++++------- htdocs/margin/productMargins.php | 31 +++++++++++++++----- htdocs/margin/tabs/productMargins.php | 14 +++++---- htdocs/margin/tabs/thirdpartyMargins.php | 14 +++++---- 5 files changed, 88 insertions(+), 43 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 5e65af70e79..f5826435ffa 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 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 @@ -40,7 +40,13 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +if (! $sortfield) +{ + if ($agentid > 0) + $sortfield="s.nom"; + else + $sortfield="u.name"; +} $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -75,7 +81,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); -print '
'; +print ''; print ''; print ''; @@ -118,10 +124,11 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) { print "
'.$langs->trans('CommercialAgent').'
"; print '
'; -$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; -$sql.= " u.login,"; -$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" ; +$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, u.rowid as agent,"; +$sql.= " u.login, u.name, u.firstname,"; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; +$sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge" ; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); @@ -155,7 +162,8 @@ if ($agentid > 0) else $sql.= " GROUP BY u.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -163,7 +171,7 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,''); $i = 0; print ""; @@ -172,7 +180,7 @@ if ($result) if ($agentid > 0) 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("CommercialAgent"),$_SERVER["PHP_SELF"],"u.name","","&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"],"buying_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); @@ -191,7 +199,7 @@ if ($result) if ($num > 0) { $var=true; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); @@ -208,9 +216,8 @@ if ($result) print "\n"; } else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "\n"; + $userstatic->fetch($objp->agent); + print "\n"; } print "\n"; print "\n"; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 06a0180a4b4..d44feb263ae 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 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 @@ -40,10 +40,6 @@ $result = restrictedArea($user, 'societe','',''); $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; @@ -77,7 +73,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); -print '
'; +print ''; print '
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".$userstatic->getFullName($langs,0,0,0)."".price($objp->selling_price)."".price($objp->buying_price)."
'; $client = false; @@ -105,6 +101,23 @@ else { print ''; } +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) +{ + if ($client) + { + $sortfield="f.datef"; + $sortorder="DESC"; + } + else + { + $sortfield="s.nom"; + $sortorder="ASC"; + } +} + // Start date print ''; print '
'.$langs->trans('StartDate').''; @@ -142,8 +155,9 @@ print ''; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client,"; $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," ; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; +$sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -166,7 +180,8 @@ if ($client) else $sql.= " GROUP BY s.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -174,7 +189,7 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,''); $i = 0; print ""; @@ -203,7 +218,7 @@ if ($result) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 183aa359c33..dd0c0901a1e 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 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 @@ -48,7 +48,20 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="p.ref"; +if (! $sortfield) +{ + if ($id > 0) + { + $sortfield="f.datef"; + $sortorder="DESC"; + } + else + { + $sortfield="p.ref"; + $sortorder="ASC"; + } +} + $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -83,7 +96,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'productMargins', $titre, 0, $picto); -print '
'; +print ''; print '
'; if ($id > 0) { @@ -144,8 +157,9 @@ print ''; $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," ; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; +$sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; @@ -170,7 +184,8 @@ if ($id > 0) else $sql.= " GROUP BY d.fk_product"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -178,7 +193,7 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',0,0,''); $i = 0; print "
"; @@ -207,7 +222,7 @@ if ($result) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 8e91670eace..c4f37667ba8 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 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 @@ -130,7 +130,10 @@ if ($id > 0 || ! empty($ref)) $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.= " d.total_ht as selling_price,"; + $sql.= " IF (f.type =2,(d.buy_price_ht * d.qty *-1),(d.buy_price_ht * d.qty)) as buying_price, "; + $sql.= " IF (f.type =2,d.qty *-1,d.qty) as qty,"; + $sql.= " IF (f.type =2,((d.price + d.buy_price_ht) * d.qty),((d.price - d.buy_price_ht) * d.qty)) as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -148,14 +151,15 @@ if ($id > 0 || ! empty($ref)) if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + // TODO: calculate total to display then restore pagination + //$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',0,0,''); $i = 0; print "
"; @@ -184,7 +188,7 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $var=!$var; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index c145e53e816..d0c0b9a67a4 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 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 @@ -128,7 +128,10 @@ if ($socid > 0) $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; - $sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price, 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," ; + $sql.= " sum(d.total_ht) as selling_price,"; + + $sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; + $sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -143,14 +146,15 @@ if ($socid > 0) $sql .= " AND d.buy_price_ht <> 0"; $sql.= " GROUP BY f.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + // TODO: calculate total to display then restore pagination + //$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - 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"],"&socid=$societe->id",$sortfield,$sortorder,'',0,0,''); $i = 0; print "
"; @@ -176,7 +180,7 @@ if ($socid > 0) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); From f8291a9efe62388b05fd3ffa79df94a7be61a576 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 18 Mar 2013 14:18:17 +0100 Subject: [PATCH 3/5] use ifsql function --- htdocs/margin/agentMargins.php | 4 ++-- htdocs/margin/customerMargins.php | 4 ++-- htdocs/margin/productMargins.php | 4 ++-- htdocs/margin/tabs/productMargins.php | 6 +++--- htdocs/margin/tabs/thirdpartyMargins.php | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index f5826435ffa..5dc39a1c6eb 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -127,8 +127,8 @@ print ''; $sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, u.rowid as agent,"; $sql.= " u.login, u.name, u.firstname,"; $sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; -$sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge" ; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge" ; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index d44feb263ae..d46133193f6 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -156,8 +156,8 @@ print ''; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client,"; $sql.= " f.facnumber, f.total as total_ht,"; $sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; -$sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge," ; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index dd0c0901a1e..04c22bb793f 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -158,8 +158,8 @@ print ''; $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.total_ht) as selling_price,"; -$sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; -$sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge," ; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index c4f37667ba8..19aa66390b1 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -131,9 +131,9 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT DISTINCT s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; $sql.= " d.total_ht as selling_price,"; - $sql.= " IF (f.type =2,(d.buy_price_ht * d.qty *-1),(d.buy_price_ht * d.qty)) as buying_price, "; - $sql.= " IF (f.type =2,d.qty *-1,d.qty) as qty,"; - $sql.= " IF (f.type =2,((d.price + d.buy_price_ht) * d.qty),((d.price - d.buy_price_ht) * d.qty)) as marge," ; + $sql.= $db->ifsql('f.type =2','(d.buy_price_ht * d.qty *-1)','(d.buy_price_ht * d.qty)')." as buying_price, "; + $sql.= $db->ifsql('f.type =2','d.qty *-1','d.qty')." as qty,"; + $sql.= $db->ifsql('f.type =2','((d.price + d.buy_price_ht) * d.qty)','((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index d0c0b9a67a4..be56cbb5589 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -130,8 +130,8 @@ if ($socid > 0) $sql.= " f.facnumber, f.total as total_ht,"; $sql.= " sum(d.total_ht) as selling_price,"; - $sql.= " IF (f.type =2,sum(d.buy_price_ht * d.qty *-1),sum(d.buy_price_ht * d.qty)) as buying_price, "; - $sql.= " IF (f.type =2,sum((d.price + d.buy_price_ht) * d.qty),sum((d.price - d.buy_price_ht) * d.qty)) as marge," ; + $sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; + $sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; From e2f28b6c519b596ec30a5219affc2d064b821053 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 18 Mar 2013 15:40:56 +0100 Subject: [PATCH 4/5] remove experimental commissions module --- htdocs/commissions/admin/commissions.php | 192 ---------- htdocs/commissions/index.php | 329 ------------------ htdocs/commissions/lib/commissions.lib.php | 52 --- htdocs/core/modules/modCommissions.class.php | 169 --------- htdocs/langs/ca_ES/commissions.lang | 41 --- htdocs/langs/en_US/commissions.lang | 44 --- htdocs/langs/es_ES/commissions.lang | 41 --- htdocs/langs/fr_FR/commissions.lang | 44 --- .../theme/auguria/img/object_commissions.png | Bin 651 -> 0 bytes .../bureau2crea/img/object_commissions.png | Bin 651 -> 0 bytes .../theme/cameleo/img/object_commissions.png | Bin 651 -> 0 bytes htdocs/theme/eldy/img/object_commissions.png | Bin 651 -> 0 bytes 12 files changed, 912 deletions(-) delete mode 100644 htdocs/commissions/admin/commissions.php delete mode 100644 htdocs/commissions/index.php delete mode 100644 htdocs/commissions/lib/commissions.lib.php delete mode 100644 htdocs/core/modules/modCommissions.class.php delete mode 100644 htdocs/langs/ca_ES/commissions.lang delete mode 100644 htdocs/langs/en_US/commissions.lang delete mode 100644 htdocs/langs/es_ES/commissions.lang delete mode 100644 htdocs/langs/fr_FR/commissions.lang delete mode 100644 htdocs/theme/auguria/img/object_commissions.png delete mode 100644 htdocs/theme/bureau2crea/img/object_commissions.png delete mode 100644 htdocs/theme/cameleo/img/object_commissions.png delete mode 100644 htdocs/theme/eldy/img/object_commissions.png diff --git a/htdocs/commissions/admin/commissions.php b/htdocs/commissions/admin/commissions.php deleted file mode 100644 index 015cab308ff..00000000000 --- a/htdocs/commissions/admin/commissions.php +++ /dev/null @@ -1,192 +0,0 @@ - - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see . - */ - -/** - * \file /htdocs/admin/commissions.php - * \ingroup commissions - * \brief Page to setup advanced commissions module - */ - -include '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/commissions/lib/commissions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); - -$langs->load("admin"); -$langs->load("bills"); -$langs->load("commissions"); - -if (! $user->admin) accessforbidden(); - - -/* - * Action - */ -if (GETPOST('commissionBase')) -{ - if (dolibarr_set_const($db, 'COMMISSION_BASE', GETPOST('commissionBase'), 'string', 0, '', $conf->entity) > 0) - { - $conf->global->COMMISSION_BASE = GETPOST('commissionBase'); - setEventMessage($langs->trans("RecordModifiedSuccessfully")); - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('productCommissionRate')) -{ - if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', GETPOST('productCommissionRate'), 'rate', 0, '', $conf->entity) > 0) - { - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('serviceCommissionRate')) -{ - if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', GETPOST('serviceCommissionRate'), 'rate', 0, '', $conf->entity) > 0) - { - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('AGENT_CONTACT_TYPE')) -{ - if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', GETPOST('AGENT_CONTACT_TYPE'), 'chaine', 0, '', $conf->entity) > 0) - { - $conf->global->AGENT_CONTACT_TYPE = GETPOST('AGENT_CONTACT_TYPE'); - } - else - { - dol_print_error($db); - } -} - -/* - * View - */ - -llxHeader('',$langs->trans("CommissionsSetup")); - - -$linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans("commissionsSetup"),$linkback,'setup'); - - -$head = commissions_admin_prepare_head(); - -dol_fiche_head($head, 'parameters', $langs->trans("Commissions"), 0, 'commissions'); - -print "
"; - - -print_fiche_titre($langs->trans("MemberMainOptions"),'',''); -print '
'; -print ''; -print ''; -print ''."\n"; -print ''."\n"; -print ''; - -$var=true; -$form = new Form($db); - -print ''; - -// COMMISSION BASE (TURNOVER / MARGIN) -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -// PRODUCT COMMISSION RATE -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -// SERVICE COMMISSION RATE -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -// INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -$var=!$var; -print ''; -print ''; -print ''; - -print '
'.$langs->trans("Description").''.$langs->trans("Value").''.$langs->trans("Details").'
'.$langs->trans("CommissionBase").''; -print 'global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "TURNOVER") - print 'checked'; -print ' />'; -print $langs->trans("CommissionBasedOnTurnover"); -print '
'; -print 'margin->enabled)) - print 'disabled'; -elseif (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "MARGIN") - print 'checked'; -print ' />'; -print $langs->trans("CommissionBasedOnMargins"); -print '
'.$langs->trans('CommissionBaseDetails'); -print '
'; -print $langs->trans('CommissionBasedOnMarginsDetails'); -print '
'.$langs->trans("ProductCommissionRate").''; -print '  %'; -print ''.$langs->trans('ProductCommissionRateDetails').'
'.$langs->trans("ServiceCommissionRate").''; -print '  %'; -print ''.$langs->trans('ServiceCommissionRateDetails').'
'.$langs->trans("AgentContactType").''; -$formcompany = new FormCompany($db); -$facture = new Facture($db); -print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE","internal","code",1); -print ''.$langs->trans('AgentContactTypeDetails').'
'; -print ''; -print '
'; - -print ''; - -dol_fiche_end(); - -print '
'; - -llxFooter(); -$db->close(); -?> diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php deleted file mode 100644 index cdc6329d858..00000000000 --- a/htdocs/commissions/index.php +++ /dev/null @@ -1,329 +0,0 @@ - - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see . - */ - -/** - * \file htdocs/commissions/index.php - * \ingroup commissions - * \brief Page des commissions par agent commercial - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->margin->enabled)) - require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; - -$langs->load("companies"); -$langs->load("bills"); -$langs->load("products"); -$langs->load("commissions"); -if (! empty($conf->margin->enabled)) - $langs->load("margins"); - -// Security check -$agentid = GETPOST('agentid','int'); - -$mesg = ''; - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$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'])) - $enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear'])); - -/* - * View - */ - -$userstatic = new User($db); -$companystatic = new Societe($db); -$invoicestatic=new Facture($db); - -$form = new Form($db); - -llxHeader('',$langs->trans("Commissions")); - -$text=$langs->trans("Commissions"); -print_fiche_titre($text); - -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"; -} - -// Start date -print ''; -print ''; -print ''; -print ''; -print ''; - -// Include unpayed invoices -print ''; - - -// Total Margin -if ($conf->global->COMMISSION_BASE == "MARGIN") { - print ''; -} -elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { - print ''; -} - -// Total Commission -print ''; - -print "
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers($agentid,'agentid',1,'',0,'',''); - print '
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers('','agentid',1,'',0,'',''); - print '
'.$langs->trans('StartDate').''; -$form->select_date($startdate,'startdate','','',1,"sel",1,1); -print ''.$langs->trans('EndDate').''; -$form->select_date($enddate,'enddate','','',1,"sel",1,1); -print ''; -print ''; -print '
'.$langs->trans("IncludeUnpayedInvoices").''; -print ''; -print '
'.$langs->trans("TotalMargin").''; - print ''; // set by jquery (see below) - print '
'.$langs->trans("TurnoverTotal").''; - print ''; // set by jquery (see below) - print '
'.$langs->trans("TotalCommission").''; -print ''; // set by jquery (see below) -print '
"; -print '
'; - -$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; -$sql.= " u.login,"; -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 == "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.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."facture as f"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); -$sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; -$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ", ".MAIN_DB_PREFIX."user as u"; -$sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= " AND sc.fk_soc = f.fk_soc"; -if (! empty($conf->global->AGENT_CONTACT_TYPE)) - $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; -else - $sql .= " AND sc.fk_user = u.rowid"; -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 ($agentid > 0) { - if (! empty($conf->global->AGENT_CONTACT_TYPE)) - $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; - else - $sql .= " AND sc.fk_user = ".$agentid; -} -if (!empty($startdate)) - $sql.= " AND f.datef >= '".$startdate."'"; -if (!empty($enddate)) - $sql.= " AND f.datef <= '".$enddate."'"; -if ($conf->global->COMMISSION_BASE == "MARGIN") - $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (($conf->global->COMMISSION_BASE == "MARGIN") && isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) - $sql .= " AND d.buy_price_ht <> 0"; -if ($agentid > 0) - $sql.= " GROUP BY s.rowid"; -else - $sql.= " GROUP BY u.rowid"; -$sql.= " ORDER BY $sortfield $sortorder "; -//$sql.= $db->plimit($conf->liste_limit +1, $offset); - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - - 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=".$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 == "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=".$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 == "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); - - // total commission - print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - print "\n"; - - $cumul_base_produit = 0; - $cumul_base_service = 0; - $cumul_commission_produit = 0; - $cumul_commission_service = 0; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); - if ($num > 0) - { - $var=True; - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($result); - - $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"; - } - - // 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 - $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 += round($productBase, $rounding); - $cumul_base_service += round($serviceBase, $rounding); - $cumul_commission_produit += round($productCommission, $rounding); - $cumul_commission_service += round($serviceCommission, $rounding); - } - } - - // affichage totaux commission - $var=!$var; - print ''; - print '"; - // product commission - print "\n"; - print "\n"; - print "\n"; - // service commission - print "\n"; - print "\n"; - print "\n"; - // total commission - print "\n"; - - print "\n"; - - print ""; - print "
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($productBase)."".price($productCommissionRate)."".price($productCommission)."".price($serviceBase)."".price($serviceCommissionRate)."".price($serviceCommission)."".price($productCommission + $serviceCommission)."
'; - print $langs->trans('Total'); - print "".price($cumul_base_produit)."".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."".price($cumul_commission_produit)."".price($cumul_base_service)."".price((! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0))."".price($cumul_commission_service)."".price($cumul_commission_produit + $cumul_commission_service)."
"; -} -else -{ - dol_print_error($db); -} -$db->free($result); - - -llxFooter(); -$db->close(); -?> - \ No newline at end of file diff --git a/htdocs/commissions/lib/commissions.lib.php b/htdocs/commissions/lib/commissions.lib.php deleted file mode 100644 index aa87720968c..00000000000 --- a/htdocs/commissions/lib/commissions.lib.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see . - */ - -/** - * \file /htdocs/commissions/lib/commissions.lib.php - * \ingroup commissions - * \brief Library for common commissions functions - */ - -/** - * Define head array for tabs of marges tools setup pages - * - * @return Array of head - */ -function commissions_admin_prepare_head() -{ - global $langs, $conf; - - $h = 0; - $head = array(); - - $head[$h][0] = DOL_URL_ROOT.'/commissions/admin/commissions.php'; - $head[$h][1] = $langs->trans("Parameters"); - $head[$h][2] = 'parameters'; - $h++; - - // Show more tabs from modules - // 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); to remove a tab - complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin'); - - complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin','remove'); - - return $head; -} - -?> diff --git a/htdocs/core/modules/modCommissions.class.php b/htdocs/core/modules/modCommissions.class.php deleted file mode 100644 index 64908f5248c..00000000000 --- a/htdocs/core/modules/modCommissions.class.php +++ /dev/null @@ -1,169 +0,0 @@ - - * Copyright (C) 2012 Laurent Destailleur - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * 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, see . - */ - -/** - * \defgroup commissions Module commissions - * \brief Module commissions - * \file htdocs/core/modules/modCommissions.class.php - * \ingroup commissions - * \brief Description and activation file for module Commissions - */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; - - -/** - * Class to describe modude Commisions - */ -class modCommissions extends DolibarrModules -{ - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 60000; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'Commissions'; - - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "financial"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i','',get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Commissions management"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 2; - // 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='commissions'; - - // Data directories to create when module is enabled. - $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@commissions"); - - // Dependencies - $this->depends = array("modFacture", "modMargin"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module - $this->langfiles = array("commissions"); - - // Constants - $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(); - - // Boxes - $this->boxes = array(); // List of boxes - $r=0; - - // Permissions - $this->rights = array(); // Permission array used by this module - $r=0; - - // Add here list of permission defined by an id, a label, a boolean and two constant strings. - // Example: - // $this->rights[$r][0] = 2000; // Permission id (must not be already used) - // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $r++; - - - // Main menu entries - $this->menu = array(); // List of menus to add - $r = 0; - - // left menu entry - $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=accountancy', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'Commissions', - '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', // 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 - $r++; - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. - * - * @return int 1 if OK, 0 if KO - */ - function init() - { - $sql = array(); - - $result=$this->load_tables(); - - return $this->_init($sql); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted. - * - * @return int 1 if OK, 0 if KO - */ - function remove() - { - $sql = array(); - - return $this->_remove($sql); - } - - - /** - * Create tables and keys required by module - * Files mymodule.sql and mymodule.key.sql with create table and create keys - * commands must be stored in directory /mymodule/sql/ - * This function is called by this->init. - * - * @return int <=0 if KO, >0 if OK - */ - function load_tables() - { - return; - } -} - -?> diff --git a/htdocs/langs/ca_ES/commissions.lang b/htdocs/langs/ca_ES/commissions.lang deleted file mode 100644 index da97a4066f2..00000000000 --- a/htdocs/langs/ca_ES/commissions.lang +++ /dev/null @@ -1,41 +0,0 @@ -# Dolibarr language file - ca_ES - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestió de comissions -commissionsSetup=Configuració de la gestió de comissions - -ProductCommissionRate=Taxa de comissió sobre els productes -ServiceCommissionRate=Taxa de comissió sobre els serveis - -ProductCommissionRateDetails=Taxa usada per calcular les comissions sobre les vendes de productes -ServiceCommissionRateDetails=Taxa usada per calcular les comissions sobre les vendes de serveis - -Commissions=Comissions -CommissionDetails=Detall de comissions - -IncludeUnpayedInvoices=Incloure les factures no cobrades -TotalCommission=Total comissions - -ProductMargin=Marge / productes -ServiceMargin=Marge / serveis - -CommissionRate=Taxes comissions - -ProductCommission=Comissió / productes -ServiceCommission=Comissió / serveis - -CommissionBase=Base de càlcul de comissions -CommissionBasedOnTurnover=Comissions calculades sobre el volum de venda -CommissionBasedOnMargins=Comissions calculades sobre els marges -CommissionBaseDetails=Estableix el mètode de càlcul de les comissions -CommissionBasedOnMarginsDetails=El càlcul basat en els marges requereix l'activació del mòdul marges - -TurnoverTotal = Volum de vendes sense IVA -ProductTurnover=Vendes sense IVA / productes -ServiceTurnover=Vendes sense IVA / serveis - -CommercialAgent=Agent comercial - -StartDate=Data d'inici -EndDate=Data de fi -Launch=Començar \ No newline at end of file diff --git a/htdocs/langs/en_US/commissions.lang b/htdocs/langs/en_US/commissions.lang deleted file mode 100644 index 776f4d0c1a1..00000000000 --- a/htdocs/langs/en_US/commissions.lang +++ /dev/null @@ -1,44 +0,0 @@ -# Dolibarr language file - fr_FR - commissions -CHARSET=UTF-8 - -Module60000Desc=Commissions management -commissionsSetup=Commissions management setup - -ProductCommissionRate=Commission rate on products -ServiceCommissionRate=Commission rate on services - -ProductCommissionRateDetails=Commission rate on product sales -ServiceCommissionRateDetails=Commission rate on service sales - -Commissions=Commissions -CommissionDetails=Commissions details - -IncludeUnpayedInvoices=Include overdue invoices -TotalCommission=Commissions subtotal - -ProductMargin=Margin / products -ServiceMargin=Margin / services - -CommissionRate=Commission rate - -ProductCommission=Commission / produics -ServiceCommission=Commission / services - -CommissionBase=Commissions base -CommissionBasedOnTurnover=Commissions based on turnover -CommissionBasedOnMargins=Commissions based on margins -CommissionBaseDetails=Define calculation method for commissions -CommissionBasedOnMarginsDetails=Commissions based on margins needs margin module activation. - -TurnoverTotal = Total turrnover -ProductTurnover=Product turnover -ServiceTurnover=Service turnover - -CommercialAgent=Commercial agent - -StartDate=Start date -EndDate=End date -Launch=Start - -AgentContactType=Contact type used for commissioning -AgentContactTypeDetails=Défine what contact type (linked on invoices) will be associated with commercial agents \ No newline at end of file diff --git a/htdocs/langs/es_ES/commissions.lang b/htdocs/langs/es_ES/commissions.lang deleted file mode 100644 index 2077ca5990c..00000000000 --- a/htdocs/langs/es_ES/commissions.lang +++ /dev/null @@ -1,41 +0,0 @@ -# Dolibarr language file - es_ES - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestión de comisiones -commissionsSetup=Configuración de la gestión de comisiones - -ProductCommissionRate=Tasa de comisión sobre los productos -ServiceCommissionRate=Tasa de comisión sobre los servicios - -ProductCommissionRateDetails=Tasa usada para calcular las comisiones sobre las ventas de productos -ServiceCommissionRateDetails=Tasa usada para calcular las comisiones sobre las ventas de servicios - -Commissions=Comisiones -CommissionDetails=Detalle de comisiones - -IncludeUnpayedInvoices=Incluir las facturas no cobradas -TotalCommission=Total comisiones - -ProductMargin=Margen / productos -ServiceMargin=Margen / servicios - -CommissionRate=Tasas comisiones - -ProductCommission=Comisión / productos -ServiceCommission=Comisión / servicios - -CommissionBase=Base de cálculo de comisiones -CommissionBasedOnTurnover=Comisiones calculadas sobre el volumen de venta -CommissionBasedOnMargins=Comisiones calculadas sobre los márgenes -CommissionBaseDetails=Establece el método de cálculo de las comisiones -CommissionBasedOnMarginsDetails=El cálculo basado en los márgenes requiere la activación del módulo márgenes - -TurnoverTotal = Volumen de ventas sin IVA -ProductTurnover=Ventas sin IVA / productos -ServiceTurnover=Ventas sin IVA / servicios - -CommercialAgent=Agente comercial - -StartDate=Fecha de inicio -EndDate=Fecha de fin -Launch=Comenzar \ No newline at end of file diff --git a/htdocs/langs/fr_FR/commissions.lang b/htdocs/langs/fr_FR/commissions.lang deleted file mode 100644 index 5fb83f32320..00000000000 --- a/htdocs/langs/fr_FR/commissions.lang +++ /dev/null @@ -1,44 +0,0 @@ -# Dolibarr language file - fr_FR - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestion des commissions -commissionsSetup=Paramétrage de la gestion des commissions - -ProductCommissionRate=Taux de commissionnement sur les produits -ServiceCommissionRate=Taux de commissionnement sur les services - -ProductCommissionRateDetails=Taux utilisé pour calculer les commissions sur les ventes de produits -ServiceCommissionRateDetails=Taux utilisé pour calculer les commissions sur les ventes de services - -Commissions=Commissions -CommissionDetails=Détail des commissions - -IncludeUnpayedInvoices=Inclure les factures non réglées -TotalCommission=Total des commissions - -ProductMargin=Marge / produits -ServiceMargin=Marge / services - -CommissionRate=Taux de commissionnement - -ProductCommission=Commission / produits -ServiceCommission=Commission / services - -CommissionBase=Base de calcul des commissions -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. - -TurnoverTotal = Chiffre d'affaire réalisé HT -ProductTurnover=CA HT / produits -ServiceTurnover=CA HT / services - -CommercialAgent=Agent commercial - -StartDate=Date de début -EndDate=Date de fin -Launch=Démarrer - -AgentContactType=Type de contact commissionné -AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera associé aux agents commerciaux \ No newline at end of file diff --git a/htdocs/theme/auguria/img/object_commissions.png b/htdocs/theme/auguria/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h diff --git a/htdocs/theme/bureau2crea/img/object_commissions.png b/htdocs/theme/bureau2crea/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h diff --git a/htdocs/theme/cameleo/img/object_commissions.png b/htdocs/theme/cameleo/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h diff --git a/htdocs/theme/eldy/img/object_commissions.png b/htdocs/theme/eldy/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h From c7666cbc3d8d9538726a8ad111ad14276bcb6653 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 20 Mar 2013 09:30:13 +0100 Subject: [PATCH 5/5] fix getting buying price when creating automatically an order from a proposal (with first option activated in workflow module) --- htdocs/commande/class/commande.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 481b51400a5..cfc88e161e2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -914,6 +914,12 @@ class Commande extends CommonOrder $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; + $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $this->lines[$i] = $line; }