diff --git a/.tx/config b/.tx/config index 0044fb91f49..028f2fdbefe 100644 --- a/.tx/config +++ b/.tx/config @@ -164,6 +164,12 @@ source_file = htdocs/langs/en_US/hrm.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.intracommreport] +file_filter = htdocs/langs//intracommreport.lang +source_file = htdocs/langs/en_US/intracommreport.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.install] file_filter = htdocs/langs//install.lang source_file = htdocs/langs/en_US/install.lang diff --git a/dev/resources/iso-normes/Intracommreport-ManuelDebXml.pdf b/dev/resources/iso-normes/Intracommreport-ManuelDebXml.pdf new file mode 100644 index 00000000000..fef9f48f53e Binary files /dev/null and b/dev/resources/iso-normes/Intracommreport-ManuelDebXml.pdf differ diff --git a/dev/resources/iso-normes/Intracommreport-ManuelDesXML.pdf b/dev/resources/iso-normes/Intracommreport-ManuelDesXML.pdf new file mode 100644 index 00000000000..b1074b3b8a3 Binary files /dev/null and b/dev/resources/iso-normes/Intracommreport-ManuelDesXML.pdf differ diff --git a/htdocs/core/boxes/intracommreport_box.php b/htdocs/core/boxes/intracommreport_box.php new file mode 100644 index 00000000000..1e7c9dd1725 --- /dev/null +++ b/htdocs/core/boxes/intracommreport_box.php @@ -0,0 +1,88 @@ + + * Copyright (C) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file 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); + } +} \ No newline at end of file diff --git a/htdocs/core/lib/intracommreport.lib.php b/htdocs/core/lib/intracommreport.lib.php new file mode 100644 index 00000000000..55a7d9ea9be --- /dev/null +++ b/htdocs/core/lib/intracommreport.lib.php @@ -0,0 +1,52 @@ + + * Copyright (C) 2015 ATM Consulting + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/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; +} diff --git a/htdocs/core/modules/modIntracommreport.class.php b/htdocs/core/modules/modIntracommreport.class.php new file mode 100644 index 00000000000..e7d5a704a67 --- /dev/null +++ b/htdocs/core/modules/modIntracommreport.class.php @@ -0,0 +1,246 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2019 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/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); + } + +} diff --git a/htdocs/core/triggers/interface_99_modintracommreport_intracommreporttrigger.class.php b/htdocs/core/triggers/interface_99_modintracommreport_intracommreporttrigger.class.php new file mode 100644 index 00000000000..73f03fb8039 --- /dev/null +++ b/htdocs/core/triggers/interface_99_modintracommreport_intracommreporttrigger.class.php @@ -0,0 +1,571 @@ + + * Copyright (C) 2015 ATM Consulting + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file 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; + } +} \ No newline at end of file diff --git a/htdocs/intracommreport/admin/index.html b/htdocs/intracommreport/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/intracommreport/admin/intracommreport.php b/htdocs/intracommreport/admin/intracommreport.php new file mode 100644 index 00000000000..7dcbbc00e2b --- /dev/null +++ b/htdocs/intracommreport/admin/intracommreport.php @@ -0,0 +1,158 @@ + + * Copyright (C) 2019 Open-DSI + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/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 = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans("IntracommReportSetup"), $linkback, 'title_setup'); + +$head = intracommReportAdminPrepareHead(); + +dol_fiche_head($head, 'general', $langs->trans("IntracommReport"), 0, "intracommreport"); + +print '
'; +print ''; +print ''; + +print ''; +print ''; +print ''."\n"; +print ''; +print ''."\n"; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print '
'.$langs->trans("Parameters").' (DEB) '.$langs->trans("Value").'
'.$langs->trans("INTRACOMMREPORT_NUM_AGREMENT").' '; +print $atmForm->texte('','TParamProDeb[INTRACOMMREPORT_NUM_AGREMENT]',$conf->global->INTRACOMMREPORT_NUM_AGREMENT,30,255); +print '
'.$langs->trans("INTRACOMMREPORT_TYPE_ACTEUR").' '; +print $atmForm->combo('','TParamProDeb[INTRACOMMREPORT_TYPE_ACTEUR]', array(''=>'', 'PSI'=>'Déclarant pour son compte', 'TDP'=>'Tiers déclarant'), $conf->global->INTRACOMMREPORT_TYPE_ACTEUR); +print '
'.$langs->trans("INTRACOMMREPORT_ROLE_ACTEUR").' '; +print $atmForm->combo('','TParamProDeb[INTRACOMMREPORT_ROLE_ACTEUR]', array(''=>'', 'sender'=>'Emetteur', 'PSI'=>'Déclarant'), $conf->global->INTRACOMMREPORT_ROLE_ACTEUR); +print '
'.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION").' '; +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 '
'.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION").' '; +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 '
'.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").' '; +print $formother->select_categories(0, $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT, 'TParamProDeb[INTRACOMMREPORT_CATEG_FRAISDEPORT]'); +print '
'; + +print '
'; +print '
'; +print ''; +print '
'; +print '
'; + +print '
'; + +print '
'; +print ''; +print ''; + +print ''; +print ''; +print ''."\n"; +print ''; +print ''."\n"; +print ''; + +print ''; +print ''; +print ''; +print ''; + +print '
'.$langs->trans("Parameters").' (DES) '.$langs->trans("Value").'
'.$langs->trans("EXPORT_PRO_DES_NUM_DECLARATION").' '; +print $atmForm->texte('','TParamProDeb[EXPORT_PRO_DES_NUM_DECLARATION]',$conf->global->EXPORT_PRO_DES_NUM_DECLARATION,30,255); +print '
'; + +print '
'; +print '
'; +print ''; +print '
'; +print '
'; + +print '
'; + +dol_fiche_end(); + +// End of page +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/intracommreport/class/actions_intracommexport.class.php b/htdocs/intracommreport/class/actions_intracommexport.class.php new file mode 100644 index 00000000000..f4bcc53863b --- /dev/null +++ b/htdocs/intracommreport/class/actions_intracommexport.class.php @@ -0,0 +1,88 @@ + + * Copyright (C) 2015 ATM Consulting + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file 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; + } + } +} \ No newline at end of file diff --git a/htdocs/intracommreport/class/deb_prodouane.class.php b/htdocs/intracommreport/class/deb_prodouane.class.php new file mode 100644 index 00000000000..01f9f4ba557 --- /dev/null +++ b/htdocs/intracommreport/class/deb_prodouane.class.php @@ -0,0 +1,321 @@ +'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(''); + + $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(''); + + $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 '.$res->nom.''; + } 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; + + } + +} diff --git a/htdocs/intracommreport/class/index.html b/htdocs/intracommreport/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/intracommreport/export.php b/htdocs/intracommreport/export.php new file mode 100644 index 00000000000..e50b548ea12 --- /dev/null +++ b/htdocs/intracommreport/export.php @@ -0,0 +1,214 @@ +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 '
'; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print 'Paramètres de l\'export'; + print '
'; + print 'Période d\'analyse'; + print ''; + $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 '
'; + print 'Type de déclaration'; + print ''; + print $ATMform->combo('','type', array('introduction'=>'Introduction', 'expedition'=>'Expédition'), $type_declaration); + print '
'; + + print '
'; + print ''; + print '
'; + + print '
'; + +} + +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 '
'; + print ''; + print ''; + print ''; + print ''; // Permet d'utiliser le bon select de la requête sql + + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + + print '
'; + print 'Paramètres de l\'export'; + print '
Période d\'analyse'; + $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 '
'; + + print '
'; + print ''; + print '
'; + + print '
'; + +} + +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'=>''.img_picto('', 'file.png').'' + ) + ,'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(); diff --git a/htdocs/intracommreport/index.html b/htdocs/intracommreport/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/langs/en_US/intracommreport.lang b/htdocs/langs/en_US/intracommreport.lang new file mode 100644 index 00000000000..8e7d2633b4d --- /dev/null +++ b/htdocs/langs/en_US/intracommreport.lang @@ -0,0 +1,7 @@ +Module104994Name = intracommreport +Module104994Desc = intracommreport Descripion + +ATMAbout = This module has been developed by ATM Consulting
You can find the documentation on our wiki

For any question or feedback, contact us on support@atm-consulting.fr

For any commercial question, contact us on contact@atm-consulting.fr or at +33 9 77 19 50 70

Find our other modules on Dolistore + +intracommreportSetup = intracommreport module setup +intracommreportAbout = About intracommreport \ No newline at end of file diff --git a/htdocs/theme/eldy/img/object_intracommreport.png b/htdocs/theme/eldy/img/object_intracommreport.png new file mode 100644 index 00000000000..08db8957e9b Binary files /dev/null and b/htdocs/theme/eldy/img/object_intracommreport.png differ diff --git a/htdocs/theme/md/img/object_intracommreport.png b/htdocs/theme/md/img/object_intracommreport.png new file mode 100644 index 00000000000..08db8957e9b Binary files /dev/null and b/htdocs/theme/md/img/object_intracommreport.png differ