NEW Module Intracomm report

This commit is contained in:
Alexandre SPANGARO 2019-05-19 10:44:09 +02:00
parent 3109f8e07a
commit f9e3a958c4
17 changed files with 1751 additions and 0 deletions

View File

@ -164,6 +164,12 @@ source_file = htdocs/langs/en_US/hrm.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.intracommreport]
file_filter = htdocs/langs/<lang>/intracommreport.lang
source_file = htdocs/langs/en_US/intracommreport.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.install]
file_filter = htdocs/langs/<lang>/install.lang
source_file = htdocs/langs/en_US/install.lang

View File

@ -0,0 +1,88 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) <year> <name of author>
*
* 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/>.
*/
/**
* \file core/boxes/mybox.php
* \ingroup intracommreport
* \brief This file is a sample box definition file
* Put some comments here
*/
include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php";
/**
* Class to manage the box
*/
class intracommreportbox extends ModeleBoxes
{
public $boxcode = "mybox";
public $boximg = "intracommreport@intracommreport";
public $boxlabel;
public $depends = array("intracommreport");
public $db;
public $param;
public $info_box_head = array();
public $info_box_contents = array();
/**
* Constructor
*/
public function __construct()
{
global $langs;
$langs->load("boxes");
$this->boxlabel = $langs->transnoentitiesnoconv("MyBox");
}
/**
* Load data into info_box_contents array to show array later.
*
* @param int $max Maximum number of records to load
* @return void
*/
public function loadBox($max = 5)
{
global $conf, $user, $langs, $db;
$this->max = $max;
//include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php";
$text = $langs->trans("MyBoxDescription", $max);
$this->info_box_head = array(
'text' => $text,
'limit' => dol_strlen($text)
);
$this->info_box_contents[0][0] = array('td' => 'align="left"',
'text' => $langs->trans("MyBoxContent"));
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
public function showBox($head = null, $contents = null)
{
parent::showBox($this->info_box_head, $this->info_box_contents);
}
}

View File

@ -0,0 +1,52 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.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 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/>.
*/
/**
* \file htdocs/core/lib/intracommreport.lib.php
* \ingroup Intracomm report
* \brief Library of intracomm report functions
*/
/**
* Prepare array with list of admin tabs
*
* @return array Array of tabs to show
*/
function intracommReportAdminPrepareHead()
{
global $langs, $conf;
$langs->load("intracommreport");
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/intracommreport/admin/intracommreport.php", 1);
$head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'general';
$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, null, $head, $h, 'intracommreport_admin');
complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport_admin', 'remove');
return $head;
}

View File

@ -0,0 +1,246 @@
<?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>
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.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 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/>.
*/
/**
* \file htdocs/core/modules/modIntracommreport.class.php
* \ingroup Intracomm report
* \brief Module to activate intracomm report double entry accounting module
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Description and activation class for module intracommreport
*/
class modIntracommreport extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $conf, $langs;
$this->db = $db;
$this->numero = 68000;
$this->family = "financial";
$this->module_position = '100';
// 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));
$this->description = "Intracomm report management (Support for French DEB/DES format)";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
$this->picto = 'intracommreport';
// Data directories to create when module is enabled
$this->dirs = array('/intracommreport/temp');
// Config pages
$this->config_page_url = array("intracommreport.php");
// Dependencies
$this->depends = array("modFacture","modTax"); // 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->conflictwith = array(); // List of modules id this module is in conflict with
$this->phpmin = array(5,5); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module
$this->langfiles = array("intracommreport");
// Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
$this->const = array();
// Tabs
$this->tabs = array();
// Css
$this->module_parts = array();
// Boxes
$this->boxes = array();
// Dictionaries
if (! isset($conf->intracommreport->enabled))
{
$conf->intracommreport=new stdClass();
$conf->intracommreport->enabled=0;
}
$this->dictionaries=array();
// Permissions
$this->rights_class = 'intracommreport';
$this->rights = array(); // Permission array used by this module
$r = 0;
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
$langs->load('intracommreport');
$this->menu[$r]=array('fk_menu'=>0, // Put 0 if this is a top menu
'type'=>'top', // This is a Top menu entry
'titre'=>$langs->trans('intracommreportDouane'),
'mainmenu'=>'intracommreport',
'leftmenu'=>'', // 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'=>'/intracommreport/export.php',
'langs'=>'intracommreport@intracommreport',
'position'=>100,
'enabled'=>'$conf->intracommreport->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
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=intracommreport', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
'titre'=>$langs->trans('intracommreportDEB'),
'mainmenu'=>'intracommreport',
'leftmenu'=>'intracommreport',
'url'=>'/intracommreport/export.php',
'position'=>100+$r,
'enabled'=>'$conf->intracommreport->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
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=intracommreport,fk_leftmenu=intracommreport', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
'titre'=>$langs->trans('intracommreportNew'),
'mainmenu'=>'intracommreport',
'leftmenu'=>'intracommreportNew',
'url'=>'/intracommreport/export.php',
'position'=>100+$r,
'enabled'=>'$conf->intracommreport->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
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=intracommreport,fk_leftmenu=intracommreport', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
'titre'=>$langs->trans('intracommreportList'),
'mainmenu'=>'intracommreport',
'leftmenu'=>'intracommreportList',
'url'=>'/intracommreport/export.php?action=list',
'position'=>100+$r,
'enabled'=>'$conf->intracommreport->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
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=intracommreport', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
'titre'=>$langs->trans('intracommreportDES'),
'mainmenu'=>'intracommreport',
'leftmenu'=>'exportprodes',
'url'=>'/intracommreport/export.php?exporttype=des',
'position'=>100+$r,
'enabled'=>'$conf->intracommreport->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
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=intracommreport,fk_leftmenu=exportprodes', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
'titre'=>$langs->trans('exportprodesNew'),
'mainmenu'=>'intracommreport',
'leftmenu'=>'exportprodes_new',
'url'=>'/intracommreport/export.php?exporttype=des',
'position'=>100+$r,
'enabled'=>'$conf->intracommreport->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
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
$this->menu[$r]=array('fk_menu'=>'fk_mainmenu=intracommreport,fk_leftmenu=exportprodes', // Put 0 if this is a top menu
'type'=>'left', // This is a Top menu entry
'titre'=>$langs->trans('exportprodesList'),
'mainmenu'=>'intracommreport',
'leftmenu'=>'exportprodes_list',
'url'=>'/intracommreport/export.php?exporttype=des&action=list',
'position'=>100+$r,
'enabled'=>'$conf->intracommreport->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
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
// Exports
$r=1;
}
/**
* 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='')
{
global $db;
$sql = array();
define('INC_FROM_DOLIBARR',true);
dol_include_once('/intracommreport/config.php');
dol_include_once('/intracommreport/script/create-maj-base.php');
$result=$this->_load_tables('/intracommreport/sql/');
$TModesTransport = array(
'options'=>array(
1=>'Transport maritime (y compris camions ou wagons sur bateau)'
,2=>'Transport par chemin de fer (y compris camions sur wagon)'
,3=>'Transport par route'
,4=>'Transport par air'
,5=>'Envois postaux'
,7=>'Installations de transport fixe (oléoduc)'
,8=>'Transport par navigation intérieure'
,9=>'Propulsion propre'
)
);
$e = new ExtraFields($db);
$e->addExtraField('mode_transport', 'Mode de transport', 'select', '', '', 'facture', 0, 0, '', $TModesTransport);
$e->addExtraField('mode_transport', 'Mode de transport', 'select', '', '', 'facture_fourn', 0, 0, '', $TModesTransport);
return $this->_init($sql, $options);
}
}

View File

@ -0,0 +1,571 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.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 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/>.
*/
/**
* \file core/triggers/interface_99_modMyodule_intracommreporttrigger.class.php
* \ingroup intracommreport
* \brief Sample trigger
* \remarks You can create other triggers by copying this one
* - File name should be either:
* interface_99_modMymodule_Mytrigger.class.php
* interface_99_all_Mytrigger.class.php
* - The file must stay in core/triggers
* - The class name must be InterfaceMytrigger
* - The constructor method must be named InterfaceMytrigger
* - The name property name must be Mytrigger
*/
/**
* Trigger class
*/
class Interfaceintracommreporttrigger
{
private $db;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
$this->name = preg_replace('/^Interface/i', '', get_class($this));
$this->family = "demo";
$this->description = "Triggers of this module are empty functions."
. "They have no effect."
. "They are provided for tutorial purpose only.";
// 'development', 'experimental', 'dolibarr' or version
$this->version = 'development';
$this->picto = 'intracommreport@intracommreport';
}
/**
* Trigger name
*
* @return string Name of trigger file
*/
public function getName()
{
return $this->name;
}
/**
* Trigger description
*
* @return string Description of trigger file
*/
public function getDesc()
{
return $this->description;
}
/**
* Trigger version
*
* @return string Version of trigger file
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') {
return $langs->trans("Development");
} elseif ($this->version == 'experimental')
return $langs->trans("Experimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else {
return $langs->trans("Unknown");
}
}
/**
* Function called when a Dolibarrr business event is done.
* All functions "run_trigger" are triggered if file
* is inside directory core/triggers
*
* @param string $action Event action code
* @param Object $object Object
* @param User $user Object user
* @param Translate $langs Object langs
* @param conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/
public function run_trigger($action, $object, $user, $langs, $conf)
{
// Put here code you want to execute when a Dolibarr business events occurs.
// Data and type of action are stored into $object and $action
// Users
if ($action == 'USER_LOGIN') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_UPDATE_SESSION') {
// Warning: To increase performances, this action is triggered only if
// constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_CREATE_FROM_CONTACT') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_NEW_PASSWORD') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_ENABLEDISABLE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_LOGOUT') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_SETINGROUP') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'USER_REMOVEFROMGROUP') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Groups
elseif ($action == 'GROUP_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'GROUP_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'GROUP_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Companies
elseif ($action == 'COMPANY_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'COMPANY_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'COMPANY_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Contacts
elseif ($action == 'CONTACT_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CONTACT_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CONTACT_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Products
elseif ($action == 'PRODUCT_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PRODUCT_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PRODUCT_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Customer orders
elseif ($action == 'ORDER_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'ORDER_CLONE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'ORDER_VALIDATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'ORDER_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'ORDER_BUILDDOC') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'ORDER_SENTBYMAIL') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEORDER_INSERT') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEORDER_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Supplier orders
elseif ($action == 'ORDER_SUPPLIER_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Proposals
elseif ($action == 'PROPAL_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_CLONE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_VALIDATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_BUILDDOC') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_SENTBYMAIL') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_CLOSE_SIGNED') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_CLOSE_REFUSED') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROPAL_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEPROPAL_INSERT') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEPROPAL_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEPROPAL_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Contracts
elseif ($action == 'CONTRACT_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CONTRACT_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CONTRACT_ACTIVATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CONTRACT_CANCEL') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CONTRACT_CLOSE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CONTRACT_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Bills
elseif ($action == 'BILL_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'BILL_CLONE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'BILL_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'BILL_VALIDATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'BILL_BUILDDOC') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'BILL_SENTBYMAIL') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'BILL_CANCEL') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'BILL_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEBILL_INSERT') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'LINEBILL_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Payments
elseif ($action == 'PAYMENT_CUSTOMER_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PAYMENT_SUPPLIER_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PAYMENT_ADD_TO_BANK') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PAYMENT_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Interventions
elseif ($action == 'FICHEINTER_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'FICHEINTER_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'FICHEINTER_VALIDATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'FICHEINTER_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Members
elseif ($action == 'MEMBER_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'MEMBER_VALIDATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'MEMBER_SUBSCRIPTION') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'MEMBER_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'MEMBER_NEW_PASSWORD') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'MEMBER_RESILIATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'MEMBER_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Categories
elseif ($action == 'CATEGORY_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CATEGORY_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'CATEGORY_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Projects
elseif ($action == 'PROJECT_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROJECT_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'PROJECT_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Project tasks
elseif ($action == 'TASK_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'TASK_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'TASK_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Task time spent
elseif ($action == 'TASK_TIMESPENT_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'TASK_TIMESPENT_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'TASK_TIMESPENT_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// Shipping
elseif ($action == 'SHIPPING_CREATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'SHIPPING_MODIFY') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'SHIPPING_VALIDATE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'SHIPPING_SENTBYMAIL') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'SHIPPING_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'SHIPPING_BUILDDOC') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
// File
elseif ($action == 'FILE_UPLOAD') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
} elseif ($action == 'FILE_DELETE') {
dol_syslog(
"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
);
}
return 0;
}
}

View File

View File

@ -0,0 +1,158 @@
<?php
/* Copyright (C) 2015 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2019 Open-DSI <support@open-dsi.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 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/>.
*/
/**
* \file htdocs/admin/intracommreport.php
* \ingroup intracommreport
* \brief Page to setup the module intracomm report
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/intracommreport.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin","intracommreport"));
if (! $user->admin) accessforbidden();
$action=__get('action','');
if($action=='save') {
foreach($_REQUEST['TParamProDeb'] as $name=>$param) {
dolibarr_set_const($db, $name, $param);
}
}
/*
* View
*/
$form=new Form($db);
$formother=new FormOther($db);
llxHeader('', $langs->trans(IntracommReportSetup));
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans("IntracommReportSetup"), $linkback, 'title_setup');
$head = intracommReportAdminPrepareHead();
dol_fiche_head($head, 'general', $langs->trans("IntracommReport"), 0, "intracommreport");
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="save">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").' (DEB)</td>'."\n";
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="center" width="100">'.$langs->trans("Value").'</td>'."\n";
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_NUM_AGREMENT").'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print $atmForm->texte('','TParamProDeb[INTRACOMMREPORT_NUM_AGREMENT]',$conf->global->INTRACOMMREPORT_NUM_AGREMENT,30,255);
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_TYPE_ACTEUR").'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print $atmForm->combo('','TParamProDeb[INTRACOMMREPORT_TYPE_ACTEUR]', array(''=>'', 'PSI'=>'Déclarant pour son compte', 'TDP'=>'Tiers déclarant'), $conf->global->INTRACOMMREPORT_TYPE_ACTEUR);
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_ROLE_ACTEUR").'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print $atmForm->combo('','TParamProDeb[INTRACOMMREPORT_ROLE_ACTEUR]', array(''=>'', 'sender'=>'Emetteur', 'PSI'=>'Déclarant'), $conf->global->INTRACOMMREPORT_ROLE_ACTEUR);
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION").'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print $atmForm->combo('','TParamProDeb[INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION]', array(0=>'', 1=>'Seuil de 460 000 €', 2=>'En dessous de 460 000 €'), $conf->global->INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION);
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION").'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print $atmForm->combo('','TParamProDeb[INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION]', array(0=>'', 3=>'Seuil de 460 000 €', 4=>'En dessous de 460 000 €'), $conf->global->INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION);
print '</td></tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print $formother->select_categories(0, $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT, 'TParamProDeb[INTRACOMMREPORT_CATEG_FRAISDEPORT]');
print '</td></tr>';
print '</table>';
print '<div class="tabsAction">';
print '<div class="inline-block divButAction">';
print '<input type="submit" name="bt_save" class="butAction" value="'.$langs->trans('Save').'" />';
print '</div>';
print '</div>';
print '</form>';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="save">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").' (DES)</td>'."\n";
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="center" width="100">'.$langs->trans("Value").'</td>'."\n";
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("EXPORT_PRO_DES_NUM_DECLARATION").'</td>';
print '<td class="center" width="20">&nbsp;</td>';
print '<td class="right" width="300">';
print $atmForm->texte('','TParamProDeb[EXPORT_PRO_DES_NUM_DECLARATION]',$conf->global->EXPORT_PRO_DES_NUM_DECLARATION,30,255);
print '</td></tr>';
print '</table>';
print '<div class="tabsAction">';
print '<div class="inline-block divButAction">';
print '<input type="submit" name="bt_save" class="butAction" value="'.$langs->trans('Save').'" />';
print '</div>';
print '</div>';
print '</form>';
dol_fiche_end();
// End of page
llxFooter();
$db->close();

View File

@ -0,0 +1,88 @@
<?php
/* <one line to give the program's name and a brief idea of what it does.>
* Copyright (C) 2015 ATM Consulting <support@atm-consulting.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 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/>.
*/
/**
* \file class/actions_intracommreport.class.php
* \ingroup intracommreport
* \brief This file is an example hook overload class file
* Put some comments here
*/
/**
* Class Actionsintracommreport
*/
class Actionsintracommreport
{
/**
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse
*/
public $results = array();
/**
* @var string String displayed by executeHook() immediately after return
*/
public $resprints;
/**
* @var array Errors
*/
public $errors = array();
/**
* Constructor
*/
public function __construct()
{
}
/**
* Overloading the doActions function : replacing the parent's function with the one below
*
* @param array() $parameters Hook metadatas (context, etc...)
* @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string &$action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
*/
function doActions($parameters, &$object, &$action, $hookmanager)
{
$error = 0; // Error counter
$myvalue = 'test'; // A result value
print_r($parameters);
echo "action: " . $action;
print_r($object);
if (in_array('somecontext', explode(':', $parameters['context'])))
{
// do something only for the context 'somecontext'
}
if (! $error)
{
$this->results = array('myreturn' => $myvalue);
$this->resprints = 'A text to show';
return 0; // or return 1 to replace standard code
}
else
{
$this->errors[] = 'Error message';
return -1;
}
}
}

View File

@ -0,0 +1,321 @@
<?php
class TDebProdouane extends TObjetStd {
static $TType = array(
'introduction'=>'Introduction'
,'expedition'=>'Expédition'
);
function __construct(&$ATMdb) {
$this->ATMdb = $ATMdb;
$this->errors = array();
parent::set_table(MAIN_DB_PREFIX.'deb_prodouane');
parent::add_champs('numero_declaration,entity','type=entier;');
parent::add_champs('type_declaration,periode,mode','type=chaine;');
parent::add_champs('content_xml','type=text;');
parent::add_champs('exporttype', array('type'=>'string', 'size'=>'10'));
parent::start();
parent::_init_vars();
$this->exporttype = 'deb';
}
/**
* @param $mode O pour création, R pour régénération (apparemment toujours 0 dans la cadre des échanges XML selon la doc)
* @param $type introduction ou expedition
*/
function getXML($mode='O', $type='introduction', $periode_reference='') {
global $db, $conf, $mysoc;
/**************Construction de quelques variables********************/
$party_id = substr(strtr($mysoc->tva_intra, array(' '=>'')), 0, 4).$mysoc->idprof2;
$declarant = substr($mysoc->managers, 0, 14);
$id_declaration = self::getNumeroDeclaration($this->numero_declaration);
/********************************************************************/
/**************Construction du fichier XML***************************/
$e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes"?><INSTAT></INSTAT>');
$enveloppe = $e->addChild('Envelope');
$enveloppe->addChild('envelopeId', $conf->global->EXPORT_PRO_DEB_NUM_AGREMENT);
$date_time = $enveloppe->addChild('DateTime');
$date_time->addChild('date', date('Y-m-d'));
$date_time->addChild('time', date('H:i:s'));
$party = $enveloppe->addChild('Party');
$party->addAttribute('partType', $conf->global->EXPORT_PRO_DEB_TYPE_ACTEUR);
$party->addAttribute('partyRole', $conf->global->EXPORT_PRO_DEB_ROLE_ACTEUR);
$party->addChild('partyId', $party_id);
$party->addChild('partyName', $declarant);
$enveloppe->addChild('softwareUsed', 'Dolibarr');
$declaration = $enveloppe->addChild('Declaration');
$declaration->addChild('declarationId', $id_declaration);
$declaration->addChild('referencePeriod', $periode_reference);
if($conf->global->EXPORT_PRO_DEB_TYPE_ACTEUR === 'PSI') $psiId = $party_id;
else $psiId = 'NA';
$declaration->addChild('PSIId', $psiId);
$function = $declaration->addChild('Function');
$functionCode = $function->addChild('functionCode', $mode);
$declaration->addChild('declarationTypeCode', $conf->global->{'EXPORT_PRO_DEB_NIV_OBLIGATION_'.strtoupper($type)});
$declaration->addChild('flowCode', ($type == 'introduction' ? 'A' : 'D'));
$declaration->addChild('currencyCode', $conf->global->MAIN_MONNAIE);
/********************************************************************/
/**************Ajout des lignes de factures**************************/
$res = self::addItemsFact($declaration, $type, $periode_reference);
/********************************************************************/
$this->errors = array_unique($this->errors);
if(!empty($res)) return $e->asXML();
else return 0;
}
// $type_declaration tjrs = "expedition" à voir si ça évolue
function getXMLDes($period_year, $period_month, $type_declaration='expedition')
{
global $db, $conf, $mysoc;
$e = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><fichier_des></fichier_des>');
$declaration_des = $e->addChild('declaration_des');
$declaration_des->addChild('num_des', self::getNumeroDeclaration($this->numero_declaration));
$declaration_des->addChild('num_tvaFr', $mysoc->tva_intra); // /^FR[a-Z0-9]{2}[0-9]{9}$/ // Doit faire 13 caractères
$declaration_des->addChild('mois_des', $period_month);
$declaration_des->addChild('an_des', $period_year);
/**************Ajout des lignes de factures**************************/
$res = self::addItemsFact($declaration_des, $type_declaration, $period_year.'-'.$period_month, 'des');
/********************************************************************/
$this->errors = array_unique($this->errors);
if(!empty($res)) return $e->asXML();
else return 0;
}
function addItemsFact(&$declaration, $type, $periode_reference, $exporttype='deb') {
global $db, $conf;
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$sql = $this->getSQLFactLines($type, $periode_reference, $exporttype);
$resql = $db->query($sql);
if($resql) {
$i=1;
if(empty($resql->num_rows)) {
$this->errors[] = 'Aucune donnée pour cette période';
return 0;
}
if($exporttype == 'deb' && $conf->global->EXPORT_PRO_DEB_CATEG_FRAISDEPORT > 0) {
$categ_fraisdeport = new Categorie($db);
$categ_fraisdeport->fetch($conf->global->EXPORT_PRO_DEB_CATEG_FRAISDEPORT);
$TLinesFraisDePort = array();
}
while($res = $db->fetch_object($resql)) {
if ($exporttype == 'des')
{
$this->addItemXMlDes($declaration, $res, '', $i);
}
else
{
if(empty($res->fk_pays)) {
// On n'arrête pas la boucle car on veut savoir quels sont tous les tiers qui n'ont pas de pays renseigné
$this->errors[] = 'Pays non renseigné pour le tiers <a href="'.dol_buildpath('/societe/soc.php',1).'?socid='.$res->id_client.'">'.$res->nom.'</a>';
} else {
if($conf->global->EXPORT_PRO_DEB_CATEG_FRAISDEPORT > 0 && $categ_fraisdeport->containsObject('product', $res->id_prod)) {
$TLinesFraisDePort[] = $res;
} else $this->addItemXMl($declaration, $res, '', $i);
}
}
$i++;
}
if(!empty($TLinesFraisDePort)) $this->addItemFraisDePort($declaration, $TLinesFraisDePort, $type, $categ_fraisdeport, $i);
if(count($this->errors) > 0) return 0;
}
return 1;
}
function getSQLFactLines($type, $periode_reference, $exporttype='deb') {
global $mysoc, $conf;
if($type=='expedition' || $exporttype=='des') {
$sql = 'SELECT f.facnumber, f.total as total_ht';
$table = 'facture';
$table_extraf = 'facture_extrafields';
$tabledet = 'facturedet';
$field_link = 'fk_facture';
}
else { // Introduction
$sql = 'SELECT f.ref_supplier as facnumber, f.total_ht';
$table = 'facture_fourn';
$table_extraf = 'facture_fourn_extrafields';
$tabledet = 'facture_fourn_det';
$field_link = 'fk_facture_fourn';
}
$sql.= ', l.fk_product, l.qty
, p.weight, p.rowid as id_prod, p.customcode
, s.rowid as id_client, s.nom, s.zip, s.fk_pays, s.tva_intra
, c.code
, ext.mode_transport
FROM '.MAIN_DB_PREFIX.$tabledet.' l
INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = l.'.$field_link.')
LEFT JOIN '.MAIN_DB_PREFIX.$table_extraf.' ext ON (ext.fk_object = f.rowid)
INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = l.fk_product)
INNER JOIN '.MAIN_DB_PREFIX.'societe s ON (s.rowid = f.fk_soc)
LEFT JOIN '.MAIN_DB_PREFIX.'c_country c ON (c.rowid = s.fk_pays)
WHERE f.fk_statut > 0
AND l.product_type = '.($exporttype == 'des' ? 1 : 0).'
AND f.entity = '.$conf->entity.'
AND (s.fk_pays <> '.$mysoc->country_id.' OR s.fk_pays IS NULL)
AND f.datef BETWEEN "'.$periode_reference.'-01" AND "'.$periode_reference.'-'.date('t').'"';
return $sql;
}
function addItemXMl(&$declaration, &$res, $code_douane_spe='', $i) {
$item = $declaration->addChild('Item');
$item->addChild('ItemNumber', $i);
$cn8 = $item->addChild('CN8');
if(empty($code_douane_spe)) $code_douane = $res->customcode;
else $code_douane = $code_douane_spe;
$cn8->addChild('CN8Code', $code_douane);
if(!empty($res->tva_intra)) $item->addChild('partnerId', $res->tva_intra);
$item->addChild('MSConsDestCode', $res->code); // code iso pays client
$item->addChild('netMass', $res->weight * $res->qty); // Poids du produit
$item->addChild('quantityInSU', $res->qty); // Quantité de produit dans la ligne
$item->addChild('invoicedAmount', round($res->total_ht)); // Montant total ht de la facture (entier attendu)
$item->addChild('invoicedNumber', $res->facnumber); // Numéro facture
$item->addChild('statisticalProcedureCode', '11');
$nature_of_transaction = $item->addChild('NatureOfTransaction');
$nature_of_transaction->addChild('natureOfTransactionACode', 1);
$nature_of_transaction->addChild('natureOfTransactionBCode', 1);
$item->addChild('modeOfTransportCode', $res->mode_transport);
$item->addChild('regionCode', substr($res->zip, 0, 2));
}
function addItemXMlDes($declaration, &$res, $code_douane_spe='', $i)
{
$item = $declaration->addChild('ligne_des');
$item->addChild('numlin_des', $i);
$item->addChild('valeur', round($res->total_ht)); // Montant total ht de la facture (entier attendu)
$item->addChild('partner_des', $res->tva_intra); // Représente le numéro TVA du client étranger
}
/**
* Cette fonction ajoute un item en récupérant le code douane du produit ayant le plus haut montant dans la facture
*/
function addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i) {
global $db, $conf;
if($type=='expedition') {
$table = 'facture';
$tabledet = 'facturedet';
$field_link = 'fk_facture';
$more_sql = 'f.facnumber';
}
else { // Introduction
$table = 'facture_fourn';
$tabledet = 'facture_fourn_det';
$field_link = 'fk_facture_fourn';
$more_sql = 'f.ref_supplier';
}
foreach($TLinesFraisDePort as $res) {
$sql = 'SELECT p.customcode
FROM '.MAIN_DB_PREFIX.$tabledet.' d
INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.')
INNER JOIN '.MAIN_DB_PREFIX.'product p ON (p.rowid = d.fk_product)
WHERE d.fk_product IS NOT NULL
AND f.entity = '.$conf->entity.'
AND '.$more_sql.' = "'.$res->facnumber.'"
AND d.total_ht =
(
SELECT MAX(d.total_ht)
FROM '.MAIN_DB_PREFIX.$tabledet.' d
INNER JOIN '.MAIN_DB_PREFIX.$table.' f ON (f.rowid = d.'.$field_link.')
WHERE d.fk_product IS NOT NULL
AND '.$more_sql.' = "'.$res->facnumber.'"
AND d.fk_product NOT IN
(
SELECT fk_product
FROM '.MAIN_DB_PREFIX.'categorie_product
WHERE fk_categorie = '.$categ_fraisdeport->id.'
)
)';
$resql = $db->query($sql);
$ress = $db->fetch_object($resql);
$this->addItemXMl($declaration, $res, $ress->customcode, $i);
$i++;
}
}
function getNextNumeroDeclaration() {
global $db;
$resql = $db->query('SELECT MAX(numero_declaration) as max_numero_declaration FROM '.$this->get_table().' WHERE exporttype="'.$this->exporttype.'"');
if($resql) $res = $db->fetch_object($resql);
return ($res->max_numero_declaration + 1);
}
// La doc impose que le numéro soit un entier positif d'un maximum de 6 caractères
static function getNumeroDeclaration($numero) {
return str_pad($numero, 6, 0, STR_PAD_LEFT);
}
function generateXMLFile() {
$name = $this->periode.'.xml';
$fname = sys_get_temp_dir().'/'.$name;
$f = fopen($fname, 'w+');
fwrite($f, $this->content_xml);
fclose($f);
header('Content-Description: File Transfer');
header('Content-Type: application/xml');
header('Content-Disposition: attachment; filename="'.$name.'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fname));
readfile($fname);
exit;
}
}

View File

View File

@ -0,0 +1,214 @@
<?php
require './config.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
dol_include_once('/intracommreport/class/deb_prodouane.class.php');
$action = GETPOST('action');
$exporttype = GETPOST('exporttype'); // DEB ou DES
if (empty($exporttype)) $exporttype = 'deb';
$PDOdb = new TPDOdb;
$ATMform = new TFormCore;
$formother = new FormOther($db);
$year = GETPOST('year');
$month = GETPOST('month');
$type_declaration = GETPOST('type');
switch($action) {
case 'generateXML':
$obj = new TDebProdouane($PDOdb);
$obj->load($PDOdb, GETPOST('id_declaration'));
$obj->generateXMLFile();
break;
case 'list':
_liste($exporttype);
break;
case 'export':
if ($exporttype == 'deb') _export_xml_deb($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
else _export_xml_des($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
default:
if ($exporttype == 'deb') _print_form_deb();
else _print_form_des();
break;
}
function _print_form_deb() {
global $langs, $ATMform, $formother, $year, $month, $type_declaration;
$langs->load('intracommreport@intracommreport');
$langs->load('main');
llxHeader();
print_fiche_titre($langs->trans('intracommreportTitle'));
dol_fiche_head();
print '<form action="'.$_SERVER['PHP_SELF'].'" name="save" method="POST">';
print '<input type="hidden" name="action" value="export" />';
print '<table width="100%" class="noborder" style="background-color: #fff;">';
print '<tr class="liste_titre">';
print '<td colspan="2">';
print 'Paramètres de l\'export';
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print 'Période d\'analyse';
print '</td>';
print '<td>';
$TabMonth = array();
for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT));
print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month);
print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5);
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print 'Type de déclaration';
print '</td>';
print '<td>';
print $ATMform->combo('','type', array('introduction'=>'Introduction', 'expedition'=>'Expédition'), $type_declaration);
print '</td>';
print '</tr>';
print '</table>';
print '<div class="tabsAction">';
print '<input class="butAction" type="SUBMIT" name="subFormExport" value="Exporter XML" />';
print '</div>';
print '</form>';
}
function _print_form_des()
{
global $langs, $ATMform, $formother, $year, $month, $type_declaration;
$langs->load('intracommreport@intracommreport');
$langs->load('main');
llxHeader();
print_fiche_titre($langs->trans('exportprodesTitle'));
dol_fiche_head();
print '<form action="'.$_SERVER['PHP_SELF'].'" name="save" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="export" />';
print '<input type="hidden" name="exporttype" value="des" />';
print '<input type="hidden" name="type" value="expedition" />'; // Permet d'utiliser le bon select de la requête sql
print '<table width="100%" class="noborder" style="background-color: #fff;">';
print '<tr class="liste_titre"><td colspan="2">';
print 'Paramètres de l\'export';
print '</td></tr>';
print '<tr>';
print '<td>Période d\'analyse</td>';
print '<td>';
$TabMonth = array();
for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT));
print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month);
print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5);
print '</td>';
print '</tr>';
print '</table>';
print '<div class="tabsAction">';
print '<input class="butAction" type="submit" value="Exporter XML" />';
print '</div>';
print '</form>';
}
function _export_xml_deb($type_declaration, $period_year, $period_month) {
global $PDOdb, $conf;
$obj = new TDebProdouane($PDOdb);
$obj->entity = $conf->entity;
$obj->mode = 'O';
$obj->periode = $period_year.'-'.$period_month;
$obj->type_declaration = $type_declaration;
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
$obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month);
if(empty($obj->errors)) {
$obj->save($PDOdb);
$obj->generateXMLFile();
}
else setEventMessage($obj->errors, 'warnings');
}
function _export_xml_des($type_declaration, $period_year, $period_month) {
global $PDOdb, $conf;
$obj = new TDebProdouane($PDOdb);
$obj->entity = $conf->entity;
$obj->periode = $period_year.'-'.$period_month;
$obj->type_declaration = $type_declaration;
$obj->exporttype = 'des';
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
$obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration);
if(empty($obj->errors)) {
$obj->save($PDOdb);
$obj->generateXMLFile();
}
else setEventMessage($obj->errors, 'warnings');
}
function _liste($exporttype='deb') {
global $db, $conf, $PDOdb, $langs;
$langs->load('intracommreport@intracommreport');
llxHeader();
$l = new TListviewTBS('intracommreport');
$sql = 'SELECT numero_declaration, type_declaration, periode, rowid as dl
FROM '.MAIN_DB_PREFIX.'deb_prodouane
WHERE entity = '.$conf->entity.' AND exporttype = '.$PDOdb->quote($exporttype);
print $l->render($PDOdb, $sql, array(
'type'=>array(
//'date_cre'=>'date'
)
,'link'=>array(
'dl'=>'<a href="'.dol_buildpath('/intracommreport/export.php', 1).'?action=generateXML&id_declaration=@dl@">'.img_picto('', 'file.png').'</a>'
)
,'eval'=>array(
'numero_declaration'=>'TDebProdouane::getNumeroDeclaration("@val@")'
,'type_declaration'=>'TDebProdouane::$TType["@val@"]'
)
,'liste'=>array(
'titre'=>$langs->trans('intracommreportList'.$exporttype)
,'image'=>img_picto('','title.png', '', 0)
,'picto_precedent'=>img_picto('','back.png', '', 0)
,'picto_suivant'=>img_picto('','next.png', '', 0)
,'messageNothing'=>"Il n'y a aucune déclaration à afficher"
,'picto_search'=>img_picto('','search.png', '', 0)
)
,'title'=>array(
'numero_declaration'=>$langs->trans('intracommreportNumber')
,'type_declaration'=>$langs->trans('intracommreportTypeDeclaration')
,'periode'=>$langs->trans('intracommreportPeriod')
,'dl'=>$langs->trans('intracommreportDownload')
)
));
}
llxFooter();

View File

View File

@ -0,0 +1,7 @@
Module104994Name = intracommreport
Module104994Desc = intracommreport Descripion
ATMAbout = This module has been developed by <a href="http://www.atm-consulting.fr" target="_blank">ATM Consulting</a><br>You can find the documentation on our <a href="http://wiki.atm-consulting.fr/index.php/Accueil" target="_blank">wiki</a><br><br>For any question or feedback, contact us on <a href="mailto:support@atm-consulting.fr">support@atm-consulting.fr</a><br><br>For any commercial question, contact us on <a href="mailto:contact@atm-consulting.fr">contact@atm-consulting.fr</a> or at +33 9 77 19 50 70<br><br>Find our other modules on <a href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=atm&submit_search=Rechercher" target="_blank">Dolistore</a>
intracommreportSetup = intracommreport module setup
intracommreportAbout = About intracommreport

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB