Skip to content
Snippets Groups Projects
Commit 6e41d645 authored by Regis Houssin's avatar Regis Houssin
Browse files

Merge pull request #251 from cbattarel/commissions

basic commissions management module
parents a109d5f3 b8fa4468
No related branches found
No related tags found
No related merge requests found
<?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
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 "<br>";
print_fiche_titre($langs->trans("MemberMainOptions"),'','');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="left">'.$langs->trans("Value").'</td>'."\n";
print '<td align="left">'.$langs->trans("Details").'</td>'."\n";
print '</tr>';
$var=true;
$form = new Form($db);
print '<form method="post">';
// COMMISSION BASE (CA / MARGES)
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("CommissionBase").'</td>';
print '<td align="left">';
print '<input type="radio" name="commissionBase" value="CA" ';
if ($conf->global->COMMISSION_BASE == "CA")
print 'checked';
print ' />';
print $langs->trans("CommissionBasedOnCA");
print '<br/>';
print '<input type="radio" name="commissionBase" value="MARGES" ';
if (!$conf->marges->enabled)
print 'disabled';
elseif ($conf->global->COMMISSION_BASE == "MARGES")
print 'checked';
print ' />';
print $langs->trans("CommissionBasedOnMargins");
print '</td>';
print '<td>'.$langs->trans('CommissionBaseDetails');
print '<br/>';
print $langs->trans('CommissionBasedOnMarginsDetails');
print '</td>';
print '</tr>';
// PRODUCT COMMISSION RATE
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("ProductCommissionRate").'</td>';
print '<td align="left">';
print '<input type="text" name="productCommissionRate" value="'.$conf->global->PRODUCT_COMMISSION_RATE.'" size=6 />&nbsp; %';
print '</td>';
print '<td>'.$langs->trans('ProductCommissionRateDetails').'</td>';
print '</tr>';
// SERVICE COMMISSION RATE
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("ServiceCommissionRate").'</td>';
print '<td align="left">';
print '<input type="text" name="serviceCommissionRate" value="'.$conf->global->SERVICE_COMMISSION_RATE.'" size=6 />&nbsp; %';
print '</td>';
print '<td>'.$langs->trans('ServiceCommissionRateDetails').'</td>';
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td align="center" colspan="3">';
print '<input type="submit" />';
print '</td>';
print '</tr>';
print '</table>';
print '<br>';
print '</form>';
$db->close();
llxFooter('$Date: 2011/07/31 22:23:21 $ - $Revision: 1.6 $');
?>
div.mainmenu.commissions {
background : url('../img/commissions.png') no-repeat 20px 0;
}
\ No newline at end of file
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
<?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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 '<form method="post" name="sel">';
print '<table class="border" width="100%">';
if ($agentid > 0) {
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
print '<td colspan="4">';
print $form->select_dolusers($selected=$agentid,$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly='');
print '</td></tr>';
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="s.nom";
}
else {
print '<tr><td width="20%">'.$langs->trans('CommercialAgent').'</td>';
print '<td colspan="4">';
print $form->select_dolusers($selected='',$htmlname='agentid',$show_empty=1,$exclude='',$disabled=0,$include='',$enableonly='');
print '</td></tr>';
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="u.login";
}
// Date dbut
print '<td>'.$langs->trans('StartDate').'</td>';
print '<td width="20%">';
$form->select_date($startdate,'startdate','','',1,"sel",1,1);
print '</td>';
print '<td width="20%">'.$langs->trans('EndDate').'</td>';
print '<td width="20%">';
$form->select_date($enddate,'enddate','','',1,"sel",1,1);
print '</td>';
print '<td style="text-align: center;">';
print '<input type="submit" value="'.$langs->trans('Launch').'" />';
print '</td></tr>';
// Include unpayed invoices
print '<tr><td>'.$langs->trans("IncludeUnpayedInvoices").'</td><td colspan="4">';
print '<input id="selIncluded" type="checkbox" name="unpayed" ';
if ($_REQUEST['unpayed'] == 'on')
print 'checked ';
print '/>';
print '</td></tr>';
// Total Margin
if ($conf->global->COMMISSION_BASE == "MARGES") {
print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalMargin").'</td><td colspan="4">';
print '<span id="totalBase"></span>'; // set by jquery (see below)
print '</td></tr>';
}
elseif ($conf->global->COMMISSION_BASE == "CA") {
print '<tr style="font-weight: bold"><td>'.$langs->trans("CATotal").'</td><td colspan="4">';
print '<span id="totalBase"></span>'; // set by jquery (see below)
print '</td></tr>';
}
// Total Commission
print '<tr style="font-weight: bold"><td>'.$langs->trans("TotalCommission").'</td><td colspan="4">';
print '<span id="totalCommission"></span>'; // set by jquery (see below)
print '</td></tr>';
print "</table>";
print '</form>';
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,";
$sql.= " u.login,";
$sql.= " f.facnumber, f.total as total_ht,";
if ($conf->global->COMMISSION_BASE == "MARGES") {
$sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ;
$sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase," ;
}
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 '<br>';
print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"&amp;socid=$societe->id",$sortfield,$sortorder,'',$num,0,'');
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
if ($agentid > 0)
print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&amp;agentid=".$_REQUEST["agentid"],'align="center"',$sortfield,$sortorder);
else
print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&amp;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","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
elseif ($conf->global->COMMISSION_BASE == "CA")
print_liste_field_titre($langs->trans("ProductCA"),$_SERVER["PHP_SELF"],"productBase","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&amp;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","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
elseif ($conf->global->COMMISSION_BASE == "CA")
print_liste_field_titre($langs->trans("ServiceCA"),$_SERVER["PHP_SELF"],"serviceBase","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
// total commission
print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&amp;agentid=".$_REQUEST["agentid"],'align="right"',$sortfield,$sortorder);
print "</tr>\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 "<tr $bc[$var]>";
if ($agentid > 0) {
$companystatic->id=$objp->socid;
$companystatic->nom=$objp->nom;
$companystatic->client=$objp->client;
print "<td>".$companystatic->getNomUrl(1,'customer')."</td>\n";
}
else {
$userstatic->id=$objp->agent;
$userstatic->login=$objp->login;
print "<td>".$userstatic->getLoginUrl(1)."</td>\n";
}
// product commission
$productCommission = $conf->global->PRODUCT_COMMISSION_RATE * $objp->productBase / 100;
print "<td align=\"right\">".price($objp->productBase)."</td>\n";
print "<td align=\"right\">".price($conf->global->PRODUCT_COMMISSION_RATE)."</td>\n";
print "<td align=\"right\">".price($productCommission)."</td>\n";
// service commission
$serviceCommission = $conf->global->SERVICE_COMMISSION_RATE * $objp->serviceBase / 100;
print "<td align=\"right\">".price($objp->serviceBase)."</td>\n";
print "<td align=\"right\">".price($conf->global->SERVICE_COMMISSION_RATE)."</td>\n";
print "<td align=\"right\">".price($serviceCommission)."</td>\n";
// total commission
print "<td align=\"right\">".price($productCommission + $serviceCommission)."</td>\n";
print "</tr>\n";
$i++;
$cumul_base_produit += $objp->productBase;
$cumul_base_service += $objp->serviceBase;
$cumul_commission_produit += $productCommission;
$cumul_commission_service += $serviceCommission;
}
}
// affichage totaux commission
$var=!$var;
print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
if ($client)
print '<td colspan=2>';
else
print '<td>';
print $langs->trans('TotalCommission')."</td>";
// product commission
print "<td align=\"right\">".price($cumul_base_produit)."</td>\n";
print "<td align=\"right\">".price($conf->global->PRODUCT_COMMISSION_RATE)."</td>\n";
print "<td align=\"right\">".price($cumul_commission_produit)."</td>\n";
// service commission
print "<td align=\"right\">".price($cumul_base_service)."</td>\n";
print "<td align=\"right\">".price($conf->global->SERVICE_COMMISSION_RATE)."</td>\n";
print "<td align=\"right\">".price($cumul_commission_service)."</td>\n";
// total commission
print "<td align=\"right\">".price($cumul_commission_produit + $cumul_commission_service)."</td>\n";
print "</tr>\n";
print "</table>";
}
else
{
dol_print_error($db);
}
$db->free($result);
$db->close();
llxFooter('$Date: 2011/08/08 16:07:47 $ - $Revision: 1.84 $');
?>
<script type="text/javascript">
$(document).ready(function() {
$("#agentid").change(function() {
$("div.fiche form").submit();
});
$("#selIncluded").change(function() {
$("div.fiche form").submit();
});
$("#totalBase").html("<?php echo price($cumul_base_produit + $cumul_base_service); ?>");
$("#totalCommission").html("<?php echo price($cumul_commission_produit + $cumul_commission_service); ?>");
});
</script>
\ No newline at end of file
<?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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
<?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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;
}
}
?>
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment