[CORE] initialisation de l'intégration du module incoterm au corp de dolibarr (#incoterm).
This commit is contained in:
parent
4c5fa7510c
commit
c7e1528594
89
htdocs/admin/incoterm.php
Normal file
89
htdocs/admin/incoterm.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("incoterm");
|
||||
$langs->load("errors");
|
||||
|
||||
if (! $user->admin) accessforbidden();
|
||||
|
||||
$action = GETPOST('action','alpha');
|
||||
$error = false;
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
if ($action == 'switch_incoterm')
|
||||
{
|
||||
$value = dolibarr_get_const($db, 'INCOTERM_ACTIVATE');
|
||||
|
||||
if (!empty($value)) $res = dolibarr_set_const($db, 'INCOTERM_ACTIVATE', 0);
|
||||
else $res = dolibarr_set_const($db, 'INCOTERM_ACTIVATE', 1);
|
||||
|
||||
|
||||
if (!$res) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
$form=new Form($db);
|
||||
|
||||
llxHeader("","");
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||
print_fiche_titre($langs->trans("IncotermSetup"),$linkback,'setup');
|
||||
print '<br>';
|
||||
|
||||
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/incoterm.php";
|
||||
$head[$h][1] = $langs->trans("Setup");
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("IncotermSetupTitle1").'</td>';
|
||||
print '<td width="20"></td>';
|
||||
print '<td align="center" width="100">'.$langs->trans("IncotermSetupTitle2").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="impair">';
|
||||
print '<td>'.$langs->trans('IncotermFunctionDesc').'</td>';
|
||||
print '<td width="20"></td>';
|
||||
print '<td width="100" align="center"><a href="'.$_SERVER["PHP_SELF"].'?action=switch_incoterm">';
|
||||
|
||||
if (!empty($conf->global->INCOTERM_ACTIVATE)) {
|
||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||
} else {
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
}
|
||||
|
||||
print '</a></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
|
||||
|
||||
142
htdocs/core/modules/modIncoterm.class.php
Normal file
142
htdocs/core/modules/modIncoterm.class.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup mymodule Module MyModule
|
||||
* \brief Example of a module descriptor.
|
||||
* Such a file must be copied into htdocs/mymodule/core/modules directory.
|
||||
* \file htdocs/mymodule/core/modules/modMyModule.class.php
|
||||
* \ingroup mymodule
|
||||
* \brief Description and activation file for module MyModule
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Description and activation class for module MyModule
|
||||
*/
|
||||
class modIncoterm extends DolibarrModules
|
||||
{
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
$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 = 210009;
|
||||
// Key text used to identify module (for permissions, menus, etc...)
|
||||
$this->rights_class = 'incoterm';
|
||||
|
||||
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
|
||||
$this->family = "products";
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Gestion des incoterm";
|
||||
$this->version = 'dolibarr';
|
||||
// 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=others,3=very specific)
|
||||
$this->special = 0;
|
||||
$this->picto='generic';
|
||||
|
||||
$this->module_parts = array();
|
||||
$this->dirs = array();
|
||||
|
||||
$this->config_page_url = array('incoterm.php');
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array(); // 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,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("incoterm");
|
||||
|
||||
$this->const = array(
|
||||
array('INCOTERM_ACTIVATE', 'smallint', 0, 'Description de INCOTERM_ACTIVATE')
|
||||
);
|
||||
|
||||
$this->tabs = array();
|
||||
|
||||
// Dictionnaries
|
||||
if (! isset($conf->incoterm->enabled)){
|
||||
@$conf->incoterm->enabled=0;
|
||||
}
|
||||
$this->dictionnaries=array(
|
||||
'langs'=>'incoterm',
|
||||
'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor
|
||||
'tablib'=>array("Incoterms"), // Label of tables
|
||||
'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields
|
||||
'tabsqlsort'=>array("rowid ASC"), // Sort order
|
||||
'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionnary)
|
||||
'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record)
|
||||
'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert)
|
||||
'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid')
|
||||
'tabcond'=>array($conf->global->INCOTERM_ACTIVATE,$conf->incoterm->enabled)
|
||||
);
|
||||
|
||||
$this->boxes = array(); // List of boxes
|
||||
$r=0;
|
||||
|
||||
// Permissions
|
||||
$this->rights = array(); // Permission array used by this module
|
||||
$r=0;
|
||||
|
||||
// Main menu entries
|
||||
$this->menus = array(); // List of menus to add
|
||||
$r=0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function init($options='')
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when module is disabled.
|
||||
* Remove from database constants, boxes and permissions from Dolibarr database.
|
||||
* Data directories are not deleted
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function remove($options='')
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
return $this->_remove($sql, $options);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -96,3 +96,67 @@ create table llx_contratdet_extrafields
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_contratdet_extrafields ADD INDEX idx_contratdet_extrafields (fk_object);
|
||||
|
||||
|
||||
--
|
||||
-- Module incoterm
|
||||
--
|
||||
ALTER TABLE llx_facture ADD COLUMN (
|
||||
fk_incoterms integer,
|
||||
location_incoterms varchar(255)
|
||||
);
|
||||
|
||||
ALTER TABLE llx_commande ADD COLUMN (
|
||||
fk_incoterms integer,
|
||||
location_incoterms varchar(255)
|
||||
);
|
||||
|
||||
ALTER TABLE llx_propal ADD COLUMN (
|
||||
fk_incoterms integer,
|
||||
location_incoterms varchar(255)
|
||||
);
|
||||
|
||||
ALTER TABLE llx_expedition ADD COLUMN (
|
||||
fk_incoterms integer,
|
||||
location_incoterms varchar(255)
|
||||
);
|
||||
|
||||
ALTER TABLE llx_livraison ADD COLUMN (
|
||||
fk_incoterms integer,
|
||||
location_incoterms varchar(255)
|
||||
);
|
||||
|
||||
ALTER TABLE llx_societe ADD COLUMN (
|
||||
fk_incoterms integer,
|
||||
location_incoterms varchar(255)
|
||||
);
|
||||
|
||||
ALTER TABLE llx_commande_fournisseur ADD COLUMN (
|
||||
fk_incoterms integer,
|
||||
location_incoterms varchar(255)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS llx_c_incoterms (
|
||||
rowid integer NOT NULL AUTO_INCREMENT,
|
||||
code varchar(3) NOT NULL,
|
||||
libelle varchar(255) NOT NULL,
|
||||
active boolean NOT NULL,
|
||||
PRIMARY KEY (rowid)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
--
|
||||
-- Content of llx_c_incoterms table
|
||||
--
|
||||
|
||||
INSERT INTO llx_c_incoterms (rowid, code, libelle, active) VALUES
|
||||
(1, 'EXW', 'Ex Works, au départ non chargé, non dédouané sortie d''usine (uniquement adapté aux flux domestiques, nationaux)', 1),
|
||||
(2, 'FCA', 'Free Carrier, marchandises dédouanées et chargées dans le pays de départ, chez le vendeur ou chez le commissionnaire de transport de l''acheteur', 1),
|
||||
(3, 'FAS', 'Free Alongside Ship, sur le quai du port de départ', 1),
|
||||
(4, 'FOB', 'Free On Board, chargé sur le bateau, les frais de chargement dans celui-ci étant fonction du liner term indiqué par la compagnie maritime (à la charge du vendeur)', 1),
|
||||
(5, 'CFR', 'Cost and Freight, chargé dans le bateau, livraison au port de départ, frais payés jusqu''au port d''arrivée, sans assurance pour le transport, non déchargé du navire à destination (les frais de déchargement sont inclus ou non au port d''arrivée)', 1),
|
||||
(6, 'CIF', 'Cost, Insurance and Freight, chargé sur le bateau, frais jusqu''au port d''arrivée, avec l''assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1),
|
||||
(7, 'CPT', 'Carriage Paid To, livraison au premier transporteur, frais jusqu''au déchargement du mode de transport, sans assurance pour le transport', 1),
|
||||
(8, 'CIP', 'Carriage and Insurance Paid to, idem CPT, avec assurance marchandise transportée souscrite par le vendeur pour le compte de l''acheteur', 1),
|
||||
(9, 'DAT', 'Delivered At Terminal, marchandises (déchargées) livrées sur quai, dans un terminal maritime, fluvial, aérien, routier ou ferroviaire désigné (dédouanement import, et post-acheminement payés par l''acheteur)', 1),
|
||||
(10, 'DAP', 'Delivered At Place, marchandises (non déchargées) mises à disposition de l''acheteur dans le pays d''importation au lieu précisé dans le contrat (déchargement, dédouanement import payé par l''acheteur)', 1),
|
||||
(11, 'DDP', 'Delivered Duty Paid, marchandises (non déchargées) livrées à destination finale, dédouanement import et taxes à la charge du vendeur ; l''acheteur prend en charge uniquement le déchargement (si exclusion des taxes type TVA, le préciser clairement)', 1);
|
||||
|
||||
6
htdocs/langs/fr_FR/incoterm.lang
Normal file
6
htdocs/langs/fr_FR/incoterm.lang
Normal file
@ -0,0 +1,6 @@
|
||||
Module210009Name=incoterm
|
||||
Module210009Desc=Ajouts pour incoterm
|
||||
IncotermSetupTitle1=Fonction
|
||||
IncotermSetupTitle2=État
|
||||
IncotermSetup=Configuration du module Incoterm
|
||||
IncotermFunctionDesc=Activer la fonction Incoterm (Société, Proposition comercial, Commande, Facture, Expédition, Livraison, Commande fournisseur)
|
||||
Loading…
Reference in New Issue
Block a user