From b8fa4468ce842800e9f60b2b89a44376807e589a Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 20 Jul 2012 16:21:35 +0200 Subject: [PATCH 1/5] add commissions module --- htdocs/admin/commissions.php | 175 ++++++++++ htdocs/commissions/css/commissions.css | 3 + htdocs/commissions/img/commissions.png | Bin 0 -> 1676 bytes htdocs/commissions/img/object_commissions.png | Bin 0 -> 651 bytes htdocs/commissions/index.php | 312 ++++++++++++++++++ htdocs/commissions/lib/commissions.lib.php | 52 +++ htdocs/core/modules/modCommissions.class.php | 185 +++++++++++ htdocs/langs/fr_FR/commissions.lang | 39 +++ 8 files changed, 766 insertions(+) create mode 100644 htdocs/admin/commissions.php create mode 100644 htdocs/commissions/css/commissions.css create mode 100644 htdocs/commissions/img/commissions.png create mode 100644 htdocs/commissions/img/object_commissions.png create mode 100644 htdocs/commissions/index.php create mode 100644 htdocs/commissions/lib/commissions.lib.php create mode 100644 htdocs/core/modules/modCommissions.class.php create mode 100644 htdocs/langs/fr_FR/commissions.lang diff --git a/htdocs/admin/commissions.php b/htdocs/admin/commissions.php new file mode 100644 index 00000000000..d29788d4d9c --- /dev/null +++ b/htdocs/admin/commissions.php @@ -0,0 +1,175 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * or see http://www.gnu.org/ + */ + +/** + * \file /marges/admin/commissions.php + * \ingroup marges + * \brief Page to setup advanced commissions module + * \version $Id:$ + */ + +$res=@include("../main.inc.php"); // For root directory + +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(); + +// 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 (dolibarr_set_const($db, 'COMMISSION_BASE', $_POST['commissionBase'], 'string', 0, '', $conf->entity) > 0) + { + $conf->global->COMMISSION_BASE = $_POST['commissionBase']; + } + else + { + dol_print_error($db); + } +} + +if (isset($_POST['productCommissionRate'])) +{ + if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', $_POST['productCommissionRate'], 'rate', 0, '', $conf->entity) > 0) + { + } + else + { + dol_print_error($db); + } +} + +if (isset($_POST['serviceCommissionRate'])) +{ + if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', $_POST['serviceCommissionRate'], 'rate', 0, '', $conf->entity) > 0) + { + } + 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($adh); + +dol_fiche_head($head, 'parameters', $langs->trans("commissions"), 0, 'company'); + +print "
"; + + +print_fiche_titre($langs->trans("MemberMainOptions"),'',''); +print ''; +print ''; +print ''; +print ''."\n"; +print ''."\n"; +print ''; + +$var=true; +$form = new Form($db); + +print ''; + +// COMMISSION BASE (CA / MARGES) +$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 ''; + +$var=!$var; +print ''; +print ''; +print ''; + + +print '
'.$langs->trans("Description").''.$langs->trans("Value").''.$langs->trans("Details").'
'.$langs->trans("CommissionBase").''; +print 'global->COMMISSION_BASE == "CA") + print 'checked'; +print ' />'; +print $langs->trans("CommissionBasedOnCA"); +print '
'; +print 'marges->enabled) + print 'disabled'; +elseif ($conf->global->COMMISSION_BASE == "MARGES") + 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').'
'; +print ''; +print '
'; +print '
'; + +print ''; + +$db->close(); + +llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.6 $'); +?> diff --git a/htdocs/commissions/css/commissions.css b/htdocs/commissions/css/commissions.css new file mode 100644 index 00000000000..72eeed1895c --- /dev/null +++ b/htdocs/commissions/css/commissions.css @@ -0,0 +1,3 @@ +div.mainmenu.commissions { + background : url('../img/commissions.png') no-repeat 20px 0; +} \ No newline at end of file diff --git a/htdocs/commissions/img/commissions.png b/htdocs/commissions/img/commissions.png new file mode 100644 index 0000000000000000000000000000000000000000..b1e139e3fbad0fd57430b5f2e9e2639a7ef92a8c GIT binary patch literal 1676 zcmV;726Op|P)F!yWy~l%DCIe%H$N?#mv2w8@CGy1*CvwjvNT&;0}HbkuFY?MDBfYyDd3WT&vZ*KWD5?NoP%j7mD34H@p1>-M111D@lCTF+m$=s@?X}TJP@OzV zW*F>QPzLBM{hjsuH|YiO?+z5;@!x(W`=&=3oSgwNK-_JkWQI|KbqK07Hfq>;2h+Cb zHR@RT95U!3TU9_sjLnfYSGaTS7TQ4q=(ixK@sKxQDKlv9`} zm-%q2NZNe#jtqo7L;%9O2k{g#H-|oYhT)+mX?p=x+0H=a1p_|5SLNonw_eY{n`kv| z)miUKvKvi=y+rEVBM}<1>tm)(g08oh0bQY(-^qY&DbE8ORIAly3)u`&y*iyc3`DPB;K#HoUuZRap;gP&vC9)Mvs0_G-6oV0PiA=dv`5X0C?B1sf5O;e zU}$8LBOeseI*+#)5Rd-)OIbKP_Rd=U_x0P@xiYPKg-$0%rjovr$>3!F76Toxy2Asj zwE~)981F@^%gZf}l%GO<4S&O9-3{rbF-9)=aR%O(R;SPY{CSsSiS@=BQofpj}2QO||}$cy{&tmzu8qT2YNDB|Gv$t7}Mq71^z@ zS@T)h@OZirQ)_k+iiv4D=!U~kf0h$-M>#n&NOSEWD~pRfd1m9St*~D4skZ|%xtM%T z-3qN44!yX5leKn^WJ^~*m!&?92n(+Zt{1Vo+MwAAalH^tw?H*fWe5>lirAO# zk4_G9_xs1(nqS3o6wHkEGW2c+{=Z}@Z?yd6T*eU$j*T!nJIJhjUXHl7h`*~G-+uG2 zeY@Ond64o?pR;i1QABB|!1#C{gCmoiI9l52f!&&YcJ=(1s-|92HIuh3M`pg(7 zjyVuST>a*Mh*V`-xg zZ#VJmb2Wo7BGvmjG-T0VvN=BY6OMe)Pd0wC|2$xtCWZV692uj#vP7`4{N@wSHq&J- zgF{7!oDuTz=^^ZV0Spr*ZgTJYyRV-IMD+oRRw6rc8fR>Z#9JU~b?AC^I&s8?Yf@_r zY_X7-G2_QaF_jRT4f2LZt7B1la*ui|q}~o*GB9e9cV3>5uFCnn0d{NInnBf?WQ+xz zA<5*--rDc>K&t~tkP>2aQpKQ)#b!H4BXY=?x@()_k3#U(?f~-@S3UKvwKoiv{IOG{ zUWo7lTJ7jYno7Ef_)eAL#&7;~=f)Oy+jmzK<&zZUVi1JCjW*W`Z(IA9UlxCL{twsP z-KV?XdgZ@i_49I4U&(WUWnTY&beN=rDb>9ml>M)E^9LX#h>q9d6P}IuO9%B WL$*wD{RmJ10000mh literal 0 HcmV?d00001 diff --git a/htdocs/commissions/img/object_commissions.png b/htdocs/commissions/img/object_commissions.png new file mode 100644 index 0000000000000000000000000000000000000000..39f09967046b32c8563a44af9da1b0b454175626 GIT binary patch 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 literal 0 HcmV?d00001 diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php new file mode 100644 index 00000000000..69e799c99f1 --- /dev/null +++ b/htdocs/commissions/index.php @@ -0,0 +1,312 @@ + + * + * 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 2 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/custom/commissions/index.php + * \ingroup commissions + * \brief Page des commissions par agent commercial + * \version $Id: facture.php,v 1.84 2011/08/08 16:07:47 eldy Exp $ + */ + +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 ($conf->marges->enabled) + require_once(DOL_DOCUMENT_ROOT."/marges/lib/marges.lib.php"); + +$langs->load("companies"); +$langs->load("bills"); +$langs->load("products"); +if ($conf->marges->enabled) + $langs->load("marges"); +$langs->load("commissions"); + +// Security check +$agentid = isset($_REQUEST["agentid"])?$_REQUEST["agentid"]:''; + +$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; + +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"; +} + +// Date début +print ''; +print ''; +print ''; +print ''; +print ''; + +// Include unpayed invoices +print ''; + + +// Total Margin +if ($conf->global->COMMISSION_BASE == "MARGES") { + print ''; +} +elseif ($conf->global->COMMISSION_BASE == "CA") { + print ''; +} + +// Total Commission +print ''; + +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('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("CATotal").''; + print ''; // set by jquery (see below) + print '
'.$langs->trans("TotalCommission").''; +print ''; // set by jquery (see below) +print '
"; +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," ; +} +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," ; +} +$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"; +$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"; +$sql.= " AND sc.fk_user = u.rowid"; +if ($_REQUEST['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") + $sql.= " AND d.buy_price_ht IS NOT NULL AND d.buy_price_ht <> 0"; +if ($agentid > 0) + $sql.= " AND sc.fk_user = $agentid"; +if (!empty($startdate)) + $sql.= " AND f.datef >= '".$startdate."'"; +if (!empty($enddate)) + $sql.= " AND f.datef <= '".$enddate."'"; +if ($agentid > 0) + $sql.= " GROUP BY s.rowid"; +else + $sql.= " GROUP BY sc.fk_user"; +$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"],"&socid=$societe->id",$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); + + // 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); + + 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); + + // 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); + + 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 "\n"; + + $cumul_base_produit = 0; + $cumul_base_service = 0; + $cumul_commission_produit = 0; + $cumul_commission_service = 0; + 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 + $productCommission = $conf->global->PRODUCT_COMMISSION_RATE * $objp->productBase / 100; + print "\n"; + print "\n"; + print "\n"; + // service commission + $serviceCommission = $conf->global->SERVICE_COMMISSION_RATE * $objp->serviceBase / 100; + print "\n"; + print "\n"; + print "\n"; + // total commission + print "\n"; + print "\n"; + $i++; + $cumul_base_produit += $objp->productBase; + $cumul_base_service += $objp->serviceBase; + $cumul_commission_produit += $productCommission; + $cumul_commission_service += $serviceCommission; + } + } + + // affichage totaux commission + $var=!$var; + print ''; + if ($client) + print '"; + // product commission + print "\n"; + print "\n"; + print "\n"; + // service commission + 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)."".price($productCommission)."".price($objp->serviceBase)."".price($conf->global->SERVICE_COMMISSION_RATE)."".price($serviceCommission)."".price($productCommission + $serviceCommission)."
'; + else + print ''; + print $langs->trans('TotalCommission')."".price($cumul_base_produit)."".price($conf->global->PRODUCT_COMMISSION_RATE)."".price($cumul_commission_produit)."".price($cumul_base_service)."".price($conf->global->SERVICE_COMMISSION_RATE)."".price($cumul_commission_service)."".price($cumul_commission_produit + $cumul_commission_service)."
"; +} +else +{ + dol_print_error($db); +} +$db->free($result); + +$db->close(); + +llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $'); +?> + \ No newline at end of file diff --git a/htdocs/commissions/lib/commissions.lib.php b/htdocs/commissions/lib/commissions.lib.php new file mode 100644 index 00000000000..b2145470df3 --- /dev/null +++ b/htdocs/commissions/lib/commissions.lib.php @@ -0,0 +1,52 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * or see http://www.gnu.org/ + */ + +/** + * \file /marges/lib/commissions.lib.php + * \ingroup marges + * \brief Library for common commissions functions + * \version $Id:$ + */ + +/** + * 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_buildpath("/commissions/admin/commissions.php",1); + $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:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'margesadmin'); + + return $head; +} + +?> \ No newline at end of file diff --git a/htdocs/core/modules/modCommissions.class.php b/htdocs/core/modules/modCommissions.class.php new file mode 100644 index 00000000000..b517cd6644e --- /dev/null +++ b/htdocs/core/modules/modCommissions.class.php @@ -0,0 +1,185 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** \defgroup mymodule Module MyModule + * \brief Example of a module descriptor. + * Such a file must be copied into htdocs/includes/module directory. + */ + +/** + * \file htdocs/includes/modules/modMyModule.class.php + * \ingroup mymodule + * \brief Description and activation file for module MyModule + * \version $Id: modMyModule.class.php,v 1.26 2008/12/15 18:27:00 eldy Exp $ + */ +include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php"); + + +/** \class modMyModule + * \brief Description and activation class for module MyModule + */ +class modCommissions extends DolibarrModules +{ + /** + * \brief Constructor. Define names, constants, directories, boxes, permissions + * \param DB Database handler + */ + function modCommissions($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 = mb_ereg_replace('^mod','',get_class($this), "i"); + // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) + $this->description = "Gestion des commissions"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = '1.0'; + // 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 = 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='commissions@commissions'; + + // Data directories to create when module is enabled. + $this->dirs = array(); + //$this->dirs[0] = DOL_DATA_ROOT.'/Marges'; + //$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp; + + // Relative path to module style sheet if exists. Example: '/mymodule/mycss.css'. + $this->style_sheet = '/commissions/css/commissions.css'; + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array("commissions.php"); + + // Dependencies + $this->depends = array("modFacture", "modMarges"); // 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(4,1); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3,1); // Minimum version of Dolibarr required by module + $this->langfiles = array("commissions"); + + // Constants + $this->const = array(); // List of particular constants to add when module is enabled + //$this->const = array( 0=>array('MAIN_MODULE_MARGES_HOOKS', 'chaine', 'propalcard', 'Hooks list for displaying Marges data on entity lists', 0, 'current', 1) ); + + // New pages on tabs + $this->tabs = array( + ); + + + // Boxes + $this->boxes = array(); // List of boxes + $r=0; + + // Add here list of php file(s) stored in includes/boxes that contains class to show a box. + // Example: + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; + + + // Permissions + $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'=>0, // Put 0 if this is a top menu + 'type'=>'top', // 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). + '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. + '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++; + + } + + /** + * \brief 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); + } + + /** + * \brief 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); + } + + + /** + * \brief 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/fr_FR/commissions.lang b/htdocs/langs/fr_FR/commissions.lang new file mode 100644 index 00000000000..a38a9e58612 --- /dev/null +++ b/htdocs/langs/fr_FR/commissions.lang @@ -0,0 +1,39 @@ +# Dolibarr language file - fr_FR - marges +CHARSET=UTF-8 + +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 + +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 +CommissionBasedOnCA=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 + +CommercialAgent=Agent commercial + +StartDate=Date de début +EndDate=Date de fin +Launch=Démarrer \ No newline at end of file From e6a192ba8727b00872607322e8d7449557523c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a?= Date: Sun, 22 Jul 2012 16:53:02 +0200 Subject: [PATCH 2/5] Renamed fk_demand_reason to fk_input_reason --- htdocs/comm/propal/class/propal.class.php | 14 +++++++------- htdocs/commande/class/commande.class.php | 14 +++++++------- htdocs/install/mysql/migration/3.2.0-3.3.0.sql | 4 ++++ htdocs/install/mysql/tables/llx_commande.sql | 2 +- htdocs/install/mysql/tables/llx_propal.sql | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5adb811bdae..3849e263596 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -673,7 +673,7 @@ class Propal extends CommonObject $sql.= ", ref_client"; $sql.= ", date_livraison"; $sql.= ", fk_availability"; - $sql.= ", fk_demand_reason"; + $sql.= ", fk_input_reason"; $sql.= ", fk_projet"; $sql.= ", entity"; $sql.= ") "; @@ -978,7 +978,7 @@ class Propal extends CommonObject $sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; $sql.= ", p.fk_adresse_livraison"; $sql.= ", p.fk_availability"; - $sql.= ", p.fk_demand_reason"; + $sql.= ", p.fk_input_reason"; $sql.= ", p.fk_cond_reglement"; $sql.= ", p.fk_mode_reglement"; $sql.= ", c.label as statut_label"; @@ -990,7 +990,7 @@ class Propal extends CommonObject $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_demand_reason = dr.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= " WHERE p.fk_statut = c.id"; $sql.= " AND p.entity = ".$conf->entity; if ($ref) $sql.= " AND p.ref='".$ref."'"; @@ -1037,7 +1037,7 @@ class Propal extends CommonObject $this->availability_id = $obj->fk_availability; $this->availability_code = $obj->availability_code; $this->availability = $obj->availability; - $this->demand_reason_id = $obj->fk_demand_reason; + $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; $this->demand_reason = $obj->demand_reason; $this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete @@ -1350,12 +1350,12 @@ class Propal extends CommonObject if ($user->rights->propale->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."propal "; - $sql.= " SET fk_demand_reason = '".$id."'"; + $sql.= " SET fk_input_reason = '".$id."'"; $sql.= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { - $this->fk_demand_reason = $id; + $this->fk_input_reason = $id; return 1; } else @@ -1944,7 +1944,7 @@ class Propal extends CommonObject if ($this->statut >= 0) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'propal'; - $sql .= ' SET fk_demand_reason = '.$demand_reason_id; + $sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' WHERE rowid='.$this->id; if ( $this->db->query($sql) ) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2341fde0c98..a1310785cd4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -632,7 +632,7 @@ class Commande extends CommonOrder $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande ("; $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, note_public, ref_client, ref_int"; - $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_demand_reason, date_livraison, fk_adresse_livraison"; + $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_availability, fk_input_reason, date_livraison, fk_adresse_livraison"; $sql.= ", remise_absolue, remise_percent"; $sql.= ", entity"; $sql.= ")"; @@ -1237,7 +1237,7 @@ class Commande extends CommonOrder if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut'; - $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_demand_reason'; + $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; @@ -1250,7 +1250,7 @@ class Commande extends CommonOrder $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON (c.fk_availability = ca.rowid)'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_demand_reason = ca.rowid)'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON (c.fk_input_reason = ca.rowid)'; $sql.= " WHERE c.entity = ".$conf->entity; if ($id) $sql.= " AND c.rowid=".$id; if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; @@ -1299,7 +1299,7 @@ class Commande extends CommonOrder $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; $this->availability_id = $obj->fk_availability; $this->availability_code = $obj->availability_code; - $this->demand_reason_id = $obj->fk_demand_reason; + $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->fk_delivery_address = $obj->fk_adresse_livraison; @@ -1906,12 +1906,12 @@ class Commande extends CommonOrder if ($user->rights->commande->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."commande "; - $sql.= " SET fk_demand_reason = '".$id."'"; + $sql.= " SET fk_input_reason = '".$id."'"; $sql.= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) { - $this->fk_demand_reason = $id; + $this->fk_input_reason = $id; return 1; } else @@ -2014,7 +2014,7 @@ class Commande extends CommonOrder if ($this->statut >= 0) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql .= ' SET fk_demand_reason = '.$demand_reason_id; + $sql .= ' SET fk_input_reason = '.$demand_reason_id; $sql .= ' WHERE rowid='.$this->id; if ( $this->db->query($sql) ) { diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index 00d8979316d..b3d3b4636eb 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -58,3 +58,7 @@ alter table llx_propaldet drop column pa_ht; alter table llx_propaldet drop column marge_tx; alter table llx_propaldet drop column marque_tx; +ALTER TABLE llx_commande CHANGE fk_demand_reason fk_input_reason INT(11) NULL DEFAULT NULL +ALTER TABLE llx_propal CHANGE fk_demand_reason fk_input_reason INT(11) NULL DEFAULT NULL + + diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 86fa9b19964..6cd66cebba0 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -62,7 +62,7 @@ create table llx_commande date_livraison date default NULL, fk_availability integer NULL, - fk_demand_reason integer, -- should be named fk_input_reason + fk_input_reason integer, fk_adresse_livraison integer, -- delivery address (deprecated) import_key varchar(14), extraparams varchar(255) -- for stock other parameters with json format diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 5238169ba04..a524676d31d 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -62,7 +62,7 @@ create table llx_propal model_pdf varchar(255), date_livraison date DEFAULT NULL, -- delivery date fk_availability integer NULL, - fk_demand_reason integer, + fk_input_reason integer, import_key varchar(14), extraparams varchar(255), -- for stock other parameters with json format fk_adresse_livraison integer -- delivery address (deprecated) From 568db22649b7264ab8a47bba8119a67be35b4927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a?= Date: Sun, 22 Jul 2012 16:58:37 +0200 Subject: [PATCH 3/5] Renamed fk_methode_commande to fk_input_method --- htdocs/fourn/class/fournisseur.commande.class.php | 8 ++++---- htdocs/install/mysql/migration/3.2.0-3.3.0.sql | 2 +- htdocs/install/mysql/tables/llx_commande_fournisseur.sql | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index f0d306be5b5..612bfb01ee0 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -119,7 +119,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " c.localtax1, c.localtax2, "; $sql.= " c.date_creation, c.date_valid, c.date_approve,"; $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve,"; - $sql.= " c.date_commande as date_commande, c.date_livraison as date_livraison, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_methode_commande,"; + $sql.= " c.date_commande as date_commande, c.date_livraison as date_livraison, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_input_method,"; $sql.= " c.note as note_private, c.note_public, c.model_pdf, c.extraparams,"; $sql.= " cm.libelle as methode_commande,"; $sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; @@ -127,7 +127,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON (c.fk_cond_reglement = cr.rowid)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON (c.fk_mode_reglement = p.id)"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_methode_commande"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method"; $sql.= " WHERE c.entity = ".$conf->entity; if ($ref) $sql.= " AND c.ref='".$ref."'"; else $sql.= " AND c.rowid=".$id; @@ -164,7 +164,7 @@ class CommandeFournisseur extends CommonOrder $this->date_commande = $this->db->jdate($obj->date_commande); // date a laquelle la commande a ete transmise $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->remise_percent = $obj->remise_percent; - $this->methode_commande_id = $obj->fk_methode_commande; + $this->methode_commande_id = $obj->fk_input_method; $this->methode_commande = $obj->methode_commande; $this->source = $obj->source; @@ -882,7 +882,7 @@ class CommandeFournisseur extends CommonOrder $result = 0; if ($user->rights->fournisseur->commande->commander) { - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 3, fk_methode_commande=".$methode.",date_commande=".$this->db->idate("$date"); + $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur SET fk_statut = 3, fk_input_method=".$methode.",date_commande=".$this->db->idate("$date"); $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::commande sql=".$sql, LOG_DEBUG); diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index b3d3b4636eb..537daf185a4 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -60,5 +60,5 @@ alter table llx_propaldet drop column marque_tx; ALTER TABLE llx_commande CHANGE fk_demand_reason fk_input_reason INT(11) NULL DEFAULT NULL ALTER TABLE llx_propal CHANGE fk_demand_reason fk_input_reason INT(11) NULL DEFAULT NULL - +ALTER TABLE llx_commande_fournisseur CHANGE fk_methode_commande fk_input_method INT(11) NULL DEFAULT '0' diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql index 7a5d2b53cfd..038f9c984dd 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql @@ -57,7 +57,7 @@ create table llx_commande_fournisseur date_livraison date default NULL, fk_cond_reglement integer, -- condition de reglement fk_mode_reglement integer, -- mode de reglement - fk_methode_commande integer default 0, -- should be named fk_input_method + fk_input_method integer default 0, import_key varchar(14), extraparams varchar(255) -- for stock other parameters with json format From 68f04de48891917da151be75f90ddb891e9775cd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 23 Jul 2012 09:45:16 +0200 Subject: [PATCH 4/5] Fix: uniformize external lang files call --- dev/skeletons/modMyModule.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 26d8ce19865..e599665b645 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -99,7 +99,7 @@ class modMyModule extends DolibarrModules $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->phpmin = array(5,0); // Minimum version of PHP required by module $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module - $this->langfiles = array("langfiles@mymodule"); + $this->langfiles = array("mylangfile@mymodule"); // Constants // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) @@ -109,8 +109,8 @@ class modMyModule extends DolibarrModules $this->const = array(); // Array to add new pages in new tabs - // Example: $this->tabs = array('objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 - // 'objecttype:+tabname2:Title2:langfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 + // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 // 'objecttype:-tabname'); // To remove an existing tab identified by code tabname // where objecttype can be // 'thirdparty' to add a tab in third party view @@ -136,7 +136,7 @@ class modMyModule extends DolibarrModules /* Example: if (! isset($conf->mymodule->enabled)) $conf->mymodule->enabled=0; // This is to avoid warnings $this->dictionnaries=array( - 'langs'=>'mymodule@mymodule', + 'langs'=>'mylangfile@mymodule', 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor 'tablib'=>array("Table1","Table2","Table3"), // Label of tables 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields @@ -188,7 +188,7 @@ class modMyModule extends DolibarrModules // 'mainmenu'=>'mymodule', // 'leftmenu'=>'mymodule', // 'url'=>'/mymodule/pagetop.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'langs'=>'mylangfile@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. // 'position'=>100, // 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules @@ -201,7 +201,7 @@ class modMyModule extends DolibarrModules // 'mainmenu'=>'mymodule', // 'leftmenu'=>'mymodule', // 'url'=>'/mymodule/pagelevel1.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'langs'=>'mylangfile@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. // 'position'=>100, // 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules @@ -216,7 +216,7 @@ class modMyModule extends DolibarrModules // 'mainmenu'=>'mainmenucode', // 'leftmenu'=>'mymodule', // 'url'=>'/mymodule/pagelevel2.php', - // 'langs'=>'mylangfile', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + // 'langs'=>'mylangfile@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. // 'position'=>100, // 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. // 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules From a109d5f32baef48efbca34dce506a4e101416782 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 23 Jul 2012 10:29:26 +0200 Subject: [PATCH 5/5] Fix: bug #467 --- htdocs/core/db/pgsql.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 2ef7e5a6ce3..34297a7c1fc 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -380,10 +380,9 @@ class DoliDBPgsql if (! $name) $name="postgres"; // When try to connect using admin user // try first Unix domain socket (local) - if ((! $host || $host == "" || $host == "localhost" || $host == "127.0.0.1") && ! defined('NOLOCALSOCKETPGCONNECT')) + if ((empty($host) || $host == "socket") && ! defined('NOLOCALSOCKETPGCONNECT')) { $con_string = "dbname='".$name."' user='".$login."' password='".$passwd."'"; // $name may be empty - //print "$con_string";exit; $this->db = pg_connect($con_string); }