diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml index 844b19c7a3f..1682b92a7a7 100644 --- a/.github/workflows/stale-issues-safe.yml +++ b/.github/workflows/stale-issues-safe.yml @@ -16,7 +16,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 10 days (you should still be able to re-open it if required).' stale-label: 'Issue Stale (automatic label)' - exempt-labels: 'Priority High / Blocking,Priority Top Strategic,Priority Medium,Hacktoberfest,good first issue,Bug Security (CVE),Analysis of PR in progres' + exempt-labels: 'Priority High / Blocking,Priority Top Strategic,Priority Medium,hacktoberfest,hacktoberfest-accepted,good first issue,Bug Security (CVE),Analysis of PR in progress' days-before-stale: 365 days-before-close: 10 operations-per-run: 100 diff --git a/.tx/config b/.tx/config index 696ff858394..b98bf7828f2 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/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 115edcef397..039dafd198f 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -196,6 +196,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install +%_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt %_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 64293ff6580..098a041680a 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -276,6 +276,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install +%_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt %_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 28b58a4da96..a3f2d1d8d96 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -193,6 +193,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install +%_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt %_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 8b4ccf37808..5b1b86b28f4 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -204,6 +204,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/imports %_datadir/dolibarr/htdocs/includes %_datadir/dolibarr/htdocs/install +%_datadir/dolibarr/htdocs/intracommreport %_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt %_datadir/dolibarr/htdocs/livraison %_datadir/dolibarr/htdocs/loan 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/admin/dict.php b/htdocs/admin/dict.php index 6e9c63ca6cf..8df2c1d36a4 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2019 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud * Copyright (C) 2019 Frédéric France @@ -91,7 +91,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 0, 15, 30, 0, 37, 0, 25, 0); +$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 41, 0, 15, 30, 0, 37, 0, 25, 0); // Name of SQL tables of dictionaries $tabname = array(); @@ -135,6 +135,7 @@ $tabname[37] = MAIN_DB_PREFIX."c_units"; $tabname[38] = MAIN_DB_PREFIX."c_socialnetworks"; $tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel"; $tabname[40] = MAIN_DB_PREFIX."c_stcommcontact"; +$tabname[41] = MAIN_DB_PREFIX."c_transport_mode"; // Dictionary labels $tablib = array(); @@ -178,6 +179,7 @@ $tablib[37] = "DictionaryMeasuringUnits"; $tablib[38] = "DictionarySocialNetworks"; $tablib[39] = "DictionaryProspectContactLevel"; $tablib[40] = "DictionaryProspectContactStatus"; +$tablib[41] = "DictionaryTransportMode"; // Requests to extract data $tabsql = array(); @@ -221,6 +223,7 @@ $tabsql[37] = "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.sc $tabsql[38] = "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks"; $tabsql[39] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel"; $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcommcontact"; +$tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode"; // Criteria to sort dictionaries $tabsqlsort = array(); @@ -264,6 +267,7 @@ $tabsqlsort[37] = "r.unit_type ASC, r.scale ASC, r.code ASC"; $tabsqlsort[38] = "rowid, code ASC"; $tabsqlsort[39] = "sortorder ASC"; $tabsqlsort[40] = "code ASC"; +$tabsqlsort[41] = "code ASC"; // Field names in select result for dictionary display $tabfield = array(); @@ -307,6 +311,7 @@ $tabfield[37] = "code,label,short_label,unit_type,scale"; $tabfield[38] = "code,label,url,icon,entity"; $tabfield[39] = "code,libelle,sortorder"; $tabfield[40] = "code,libelle,picto"; +$tabfield[41] = "code,label"; // Edit field names for editing a record $tabfieldvalue = array(); @@ -350,6 +355,7 @@ $tabfieldvalue[37] = "code,label,short_label,unit_type,scale"; $tabfieldvalue[38] = "code,label,url,icon"; $tabfieldvalue[39] = "code,libelle,sortorder"; $tabfieldvalue[40] = "code,libelle,picto"; +$tabfieldvalue[41] = "code,label"; // Field names in the table for inserting a record $tabfieldinsert = array(); @@ -394,6 +400,7 @@ $tabfieldinsert[37] = "code,label,short_label,unit_type,scale"; $tabfieldinsert[38] = "code,label,url,icon,entity"; $tabfieldinsert[39] = "code,label,sortorder"; $tabfieldinsert[40] = "code,libelle,picto"; +$tabfieldinsert[41] = "code,label"; // Rowid name of field depending if field is autoincrement on or off.. // Use "" if id field is "rowid" and has autoincrement on @@ -439,6 +446,7 @@ $tabrowid[37] = ""; $tabrowid[38] = ""; $tabrowid[39] = "code"; $tabrowid[40] = "id"; +$tabrowid[41] = ""; // Condition to show dictionary in setup page $tabcond = array(); @@ -482,6 +490,7 @@ $tabcond[37] = !empty($conf->product->enabled); $tabcond[38] = !empty($conf->socialnetworks->enabled); $tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)); $tabcond[40] = (!empty($conf->societe->enabled) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)); +$tabcond[41] = !empty($conf->intracommreport->enabled); // List of help for fields $tabhelp = array(); @@ -525,6 +534,7 @@ $tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $lang $tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc')); $tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp")); +$tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode")); // List of check for fields (NOT USED YET) $tabfieldcheck = array(); @@ -568,6 +578,7 @@ $tabfieldcheck[37] = array(); $tabfieldcheck[38] = array(); $tabfieldcheck[39] = array(); $tabfieldcheck[40] = array(); +$tabfieldcheck[41] = array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index c61e352aad8..3ca08f90900 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -662,9 +662,9 @@ if ($mode == 'common' || $mode == 'commonkanban') // Version (with picto warning or not) $version = $objMod->getVersion(0); $versiontrans = ''; - if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"'); - if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"'); - if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"'); + if (preg_match('/development/i', $version)) $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); + if (preg_match('/experimental/i', $version)) $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); + if (preg_match('/deprecated/i', $version)) $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { $versiontrans .= $objMod->getVersion(1); } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index d3a60d76e14..8dabe102066 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -487,6 +487,27 @@ if ($object->id > 0) print ''; } + if (! empty($conf->intracommreport->enabled)) + { + // Transport mode by default + print ''; + print ''; + print '
'; + print $langs->trans('IntracommReportTransportMode'); + print ''; + if (($action != 'edittransportmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; + print ''; + if ($action == 'edittransportmode') + { + $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'fk_transport_mode', 1); + } + else { + $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_transport_mode, 'none'); + } + print ""; + print ''; + } + // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { $langs->load("categories"); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f2aab587169..70df565cd2b 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3994,11 +3994,6 @@ class OrderLine extends CommonOrderLine public $fk_parent_line; public $fk_facture; - /** - * @var string Order lines label - */ - public $label; - public $ref_ext; public $fk_remise_except; @@ -4049,7 +4044,7 @@ class OrderLine extends CommonOrderLine $sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,'; $sql .= ' cd.fk_unit,'; $sql .= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,'; - $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc, p.tobatch as product_tobatch,'; + $sql .= ' p.ref as product_ref, p.label as product_label, p.description as product_desc, p.tobatch as product_tobatch,'; $sql .= ' cd.date_start, cd.date_end'; $sql .= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; @@ -4093,9 +4088,9 @@ class OrderLine extends CommonOrderLine $this->rang = $objp->rang; $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated - $this->product_label = $objp->product_libelle; + + $this->product_ref = $objp->product_ref; + $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; $this->product_tobatch = $objp->product_tobatch; $this->fk_unit = $objp->fk_unit; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8ec349c79f4..0c6b438b376 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4738,10 +4738,7 @@ class FactureLigne extends CommonInvoiceLine public $fk_facture; //! Id parent line public $fk_parent_line; - /** - * @deprecated - */ - public $label; + //! Description ligne public $desc; public $ref_ext; // External reference of the line @@ -4771,21 +4768,6 @@ class FactureLigne extends CommonInvoiceLine public $date_start; public $date_end; - // From llx_product - /** - * @deprecated - * @see $product_ref - */ - public $ref; // Product ref (deprecated) - public $product_ref; // Product ref - /** - * @deprecated - * @see $product_label - */ - public $libelle; // Product label (deprecated) - public $product_label; // Product label - public $product_desc; // Description produit - public $skip_update_total; // Skip update price total for special lines /** @@ -4825,7 +4807,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ' fd.multicurrency_total_ht,'; $sql .= ' fd.multicurrency_total_tva,'; $sql .= ' fd.multicurrency_total_ttc,'; - $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql .= ' p.ref as product_ref, p.label as product_label, p.description as product_desc'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; $sql .= ' WHERE fd.rowid = '.$rowid; @@ -4871,10 +4853,11 @@ class FactureLigne extends CommonInvoiceLine $this->marque_tx = $marginInfos[2]; $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated - $this->product_label = $objp->product_libelle; + + $this->product_ref = $objp->product_ref; + $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; + $this->fk_unit = $objp->fk_unit; $this->fk_user_modif = $objp->fk_user_modif; $this->fk_user_author = $objp->fk_user_author; diff --git a/htdocs/core/boxes/intracommreport_box.php b/htdocs/core/boxes/intracommreport_box.php new file mode 100644 index 00000000000..1df09500173 --- /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"; + 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); + } +} diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 98890744701..920dd42f515 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -815,6 +815,47 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; */ abstract class CommonInvoiceLine extends CommonObjectLine { + /** + * Custom label of line. Not used by default. + * @deprecated + */ + public $label; + + /** + * @deprecated + * @see $product_ref + */ + public $ref; // Product ref (deprecated) + /** + * @deprecated + * @see $product_label + */ + public $libelle; // Product label (deprecated) + + /** + * Type of the product. 0 for product 1 for service + * @var int + */ + public $product_type = 0; + + /** + * Product ref + * @var string + */ + public $product_ref; + + /** + * Product label + * @var string + */ + public $product_label; + + /** + * Product description + * @var string + */ + public $product_desc; + /** * Quantity * @var double @@ -827,12 +868,6 @@ abstract class CommonInvoiceLine extends CommonObjectLine */ public $subprice; - /** - * Type of the product. 0 for product 1 for service - * @var int - */ - public $product_type = 0; - /** * Id of corresponding product * @var int diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3ea4bba4a7f..ea38df7a826 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -296,6 +296,12 @@ abstract class CommonObject */ public $cond_reglement_id; + /** + * @var int Transport mode ID (For module intracomm report) + * @see setTransportMode() + */ + public $transport_mode_id; + /** * @var int Payment terms ID * @deprecated Kept for compatibility @@ -1999,7 +2005,7 @@ abstract class CommonObject if (get_class($this) == 'Fournisseur') $this->mode_reglement_supplier_id = $id; return 1; } else { - dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error()); + dol_syslog(get_class($this).'::setPaymentMethods Error '.$sql.' - '.$this->db->error()); $this->error = $this->db->error(); return -1; } @@ -2036,7 +2042,7 @@ abstract class CommonObject return 1; } else { - dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error()); + dol_syslog(get_class($this).'::setMulticurrencyCode Error '.$sql.' - '.$this->db->error()); $this->error = $this->db->error(); return -1; } @@ -2140,7 +2146,7 @@ abstract class CommonObject return 1; } else { - dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error()); + dol_syslog(get_class($this).'::setMulticurrencyRate Error '.$sql.' - '.$this->db->error()); $this->error = $this->db->error(); return -1; } @@ -2179,7 +2185,7 @@ abstract class CommonObject $this->cond_reglement = $id; // for compatibility return 1; } else { - dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error()); + dol_syslog(get_class($this).'::setPaymentTerms Error '.$sql.' - '.$this->db->error()); $this->error = $this->db->error(); return -1; } @@ -2190,6 +2196,42 @@ abstract class CommonObject } } + /** + * Change the transport mode methods + * + * @param int $id Id of new payment method + * @return int >0 if OK, <0 if KO + */ + public function setTransportMode($id) + { + dol_syslog(get_class($this).'::setTransportMode('.$id.')'); + if ($this->statut >= 0 || $this->element == 'societe') + { + $fieldname = 'fk_transport_mode'; + if ($this->element == 'societe') $fieldname = 'transport_mode'; + if (get_class($this) == 'Fournisseur') $fieldname = 'transport_mode_supplier'; + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); + $sql .= ' WHERE rowid='.$this->id; + + if ($this->db->query($sql)) + { + $this->transport_mode_id = $id; + // for supplier + if (get_class($this) == 'Fournisseur') $this->transport_mode_supplier_id = $id; + return 1; + } else { + dol_syslog(get_class($this).'::setTransportMode Error '.$sql.' - '.$this->db->error()); + $this->error=$this->db->error(); + return -1; + } + } else { + dol_syslog(get_class($this).'::setTransportMode, status of the object is incompatible'); + $this->error='Status of the object is incompatible '.$this->statut; + return -2; + } + } /** * Change the retained warranty payments terms @@ -2213,7 +2255,7 @@ abstract class CommonObject $this->retained_warranty_fk_cond_reglement = $id; return 1; } else { - dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error()); + dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Error '.$sql.' - '.$this->db->error()); $this->error = $this->db->error(); return -1; } @@ -2245,7 +2287,7 @@ abstract class CommonObject return 1; } else { $this->error = $this->db->error(); - dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error); + dol_syslog(get_class($this).'::setDeliveryAddress Error '.$sql.' - '.$this->error); return -1; } } @@ -8286,7 +8328,7 @@ abstract class CommonObject * @param int $fromId Id object source * @param int $toId Id object cible * @param string $type Type of category ('product', ...) - * @return int < 0 si erreur, > 0 si ok + * @return int < 0 if error, > 0 if ok */ public function cloneCategories($fromId, $toId, $type = '') { diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 83d20e99b95..8874175a138 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -38,6 +38,12 @@ abstract class CommonOrder extends CommonObject */ abstract class CommonOrderLine extends CommonObjectLine { + /** + * Custom label of line. Not used by default. + * @deprecated + */ + public $label; + /** * Product ref * @var string @@ -46,12 +52,6 @@ abstract class CommonOrderLine extends CommonObjectLine */ public $ref; - /** - * Product ref - * @var string - */ - public $product_ref; - /** * Product label * @var string @@ -60,6 +60,12 @@ abstract class CommonOrderLine extends CommonObjectLine */ public $libelle; + /** + * Product ref + * @var string + */ + public $product_ref; + /** * Product label * @var string diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 32d7b145a41..3d6526690a7 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -203,7 +203,7 @@ class Conf { $modulename = strtolower($reg[1]); $partname = strtolower($reg[2]); - if (!is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } + if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } $arrValue = json_decode($value, true); if (is_array($arrValue) && !empty($arrValue)) $value = $arrValue; elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d5d6e59dcb3..feddd6e4f24 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -71,6 +71,7 @@ class Form // Cache arrays public $cache_types_paiements = array(); public $cache_conditions_paiements = array(); + public $cache_transport_mode = array(); public $cache_availability = array(); public $cache_demand_reason = array(); public $cache_types_fees = array(); @@ -3548,6 +3549,107 @@ class Form return $return; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load in cache list of transport mode + * + * @return int Nb of lines loaded, <0 if KO + */ + public function load_cache_transport_mode() + { + // phpcs:enable + global $langs; + + $num=count($this->cache_transport_mode); + if ($num > 0) return $num; // Cache already loaded + + dol_syslog(__METHOD__, LOG_DEBUG); + + $this->cache_transport_mode = array(); + + $sql = "SELECT rowid, code, label, active"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_transport_mode"; + $sql.= " WHERE entity IN (".getEntity('c_transport_mode').")"; + //if ($active >= 0) $sql.= " AND active = ".$active; + + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + // If traduction exist, we use it else we take the default label + $label=($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code)!=("PaymentTypeShort".$obj->code)?$langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code):($obj->label!='-'?$obj->label:'')); + $this->cache_transport_mode[$obj->rowid]['rowid'] = $obj->rowid; + $this->cache_transport_mode[$obj->rowid]['code'] = $obj->code; + $this->cache_transport_mode[$obj->rowid]['label']= $label; + $this->cache_transport_mode[$obj->rowid]['active'] = $obj->active; + $i++; + } + + $this->cache_transport_mode = dol_sort_array($this->cache_transport_mode, 'label', 'asc', 0, 0, 1); + + return $num; + } + else { + dol_print_error($this->db); + return -1; + } + } + + /** + * Return list of transport mode for intracomm report + * + * @param string $selected Id of the transport mode pre-selected + * @param string $htmlname Name of the select field + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int $empty 1=can be empty, 0 else + * @param int $noadmininfo 0=Add admin info, 1=Disable admin info + * @param int $maxlength Max length of label + * @param int $active Active or not, -1 = all + * @param string $morecss Add more CSS on select tag + * @return void + */ + public function selectTransportMode($selected = '', $htmlname = 'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + { + global $langs,$user; + + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$format, LOG_DEBUG); + + $this->load_cache_transport_mode(); + + print ''; + if ($user->admin && ! $noadmininfo) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + /** * Return a HTML select list of shipping mode * @@ -4581,7 +4683,40 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show form with transport mode + * + * @param string $page Page + * @param int $selected Id mode pre-select + * @param string $htmlname Name of select html field + * @param int $active Active or not, -1 = all + * @param int $addempty 1=Add empty entry + * @return void + */ + public function formSelectTransportMode($page, $selected = '', $htmlname = 'transport_mode_id', $active = 1, $addempty = 0) + { + global $langs; + if ($htmlname != "none") + { + print '
'; + print ''; + print ''; + $this->selectTransportMode($selected, $htmlname, 2, $addempty, 0, 0, $active); + print ''; + print '
'; + } + else { + if ($selected) + { + $this->load_cache_transport_mode(); + print $this->cache_transport_mode[$selected]['label']; + } else { + print " "; + } + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with multicurrency code * diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 038b4be27a6..49ababf4a25 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -45,7 +45,7 @@ function versiontostring($versionarray) /** * Compare 2 versions (stored into 2 arrays). * To check if Dolibarr version is lower than (x,y,z), do "if versioncompare(versiondolibarrarray(), array(x.y.z)) <= 0" - * For example: if (versioncompare(versiondolibarrarray(),array(4,0,-4)) >= 0) is true if version is 4.0 alpha or higher. + * For example: if (versioncompare(versiondolibarrarray(),array(4,0,-5)) >= 0) is true if version is 4.0 alpha or higher. * For example: if (versioncompare(versiondolibarrarray(),array(4,0,0)) >= 0) is true if version is 4.0 final or higher. * For example: if (versioncompare(versiondolibarrarray(),array(4,0,1)) >= 0) is true if version is 4.0.1 or higher. * Alternative way to compare: if ((float) DOL_VERSION >= 4.0) is true if version is 4.0 alpha or higher (works only to compare first and second level) diff --git a/htdocs/core/lib/intracommreport.lib.php b/htdocs/core/lib/intracommreport.lib.php new file mode 100644 index 00000000000..425e53f3bcf --- /dev/null +++ b/htdocs/core/lib/intracommreport.lib.php @@ -0,0 +1,81 @@ + + * 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_URL_ROOT.'/intracommreport/admin/intracommreport.php'; + $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; +} + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to show + */ +function intracommReportPrepareHead() +{ + global $langs, $conf; + + $langs->load("intracommreport"); + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/intracommreport/card.php?rowid='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $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'); + + complete_head_from_modules($conf, $langs, null, $head, $h, 'intracommreport', 'remove'); + return $head; +} diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5e4b98f7461..33380c531f1 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -332,9 +332,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Accounting $tmpentry = array( - 'enabled'=>(!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->asset->enabled)), - 'perms'=>(!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->mouvements->lire) || !empty($user->rights->asset->read)), - 'module'=>'comptabilite|accounting|asset' + 'enabled'=>(!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled) || !empty($conf->asset->enabled) || !empty($conf->intracommreport->enabled)), + 'perms'=>(!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->mouvements->lire) || !empty($user->rights->asset->read) || !empty($user->rights->intracommreport->read)), + 'module'=>'comptabilite|accounting|asset|intracommreport' ); $menu_arr[] = array( 'name' => 'Accounting', @@ -353,7 +353,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'session' => (($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") ? 0 : 1), - 'loadLangs' => array("compta", "accountancy", "assets"), + 'loadLangs' => array("compta", "accountancy", "assets","intracommreport"), 'submenus' => array(), ); @@ -1439,6 +1439,17 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journals"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); } + // Intracomm report + if (! empty($conf->intracommreport->enabled)) + { + $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); + if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { + // DEB / DES + $newmenu->add("/intracommreport/card.php?action=create&leftmenu=intracommreport", $langs->trans("MenuIntracommReportNew"), 1, $user->rights->intracommreport->write, '', $mainmenu, 'intracommreport', 1); + $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReportList"), 1, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); + } + } + // Assets if (!empty($conf->asset->enabled)) { diff --git a/htdocs/core/modules/modIntracommreport.class.php b/htdocs/core/modules/modIntracommreport.class.php new file mode 100644 index 00000000000..42e906a15f2 --- /dev/null +++ b/htdocs/core/modules/modIntracommreport.class.php @@ -0,0 +1,129 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * 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/core/modules/modIntracommreport.class.php + * \ingroup Intracomm report + * \brief Module to activate intracomm report 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 + */ + public 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 = 'development'; + + $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@intracommreport"); + + // 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(13, 0, -5); // 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 = array(); + $this->rights_class = 'intracommreport'; + $r = 0; + + $r++; + $this->rights[$r][0] = 68001; + $this->rights[$r][1] = 'Read intracomm report'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; + + $r++; + $this->rights[$r][0] = 68002; + $this->rights[$r][1] = 'Create/modify intracomm report'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + + $r++; + $this->rights[$r][0] = 68004; + $this->rights[$r][1] = 'Delete intracomm report'; + $this->rights[$r][2] = 'd'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; + + // Exports + $r=1; + } +} diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 300a5032a2c..df0bb21a318 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3291,11 +3291,6 @@ class CommandeFournisseurLigne extends CommonOrderLine */ public $fk_facture; - /** - * @var string supplier order line label - */ - public $label; - public $rang = 0; public $special_code = 0; @@ -3316,7 +3311,6 @@ class CommandeFournisseurLigne extends CommonOrderLine */ public $ref_supplier; public $remise; - public $product_libelle; /** @@ -3344,7 +3338,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ' cd.remise, cd.remise_percent, cd.subprice,'; $sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,'; $sql .= ' cd.total_localtax1, cd.total_localtax2,'; - $sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,'; + $sql .= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; $sql .= ' cd.date_start, cd.date_end, cd.fk_unit,'; $sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) @@ -3387,8 +3381,9 @@ class CommandeFournisseurLigne extends CommonOrderLine $this->special_code = $objp->special_code; $this->ref = $objp->product_ref; + $this->product_ref = $objp->product_ref; - $this->product_libelle = $objp->product_libelle; + $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 589c4e82fc9..1761215705b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -98,12 +98,18 @@ class FactureFournisseur extends CommonInvoice */ public $ref; - public $label; - public $libelle; // @deprecated - - public $product_ref; + /** + * @var string Ref supplier + */ public $ref_supplier; + + /** + * @var string Label of invoice + */ + public $label; + public $socid; + //Check constants for types public $type = self::TYPE_STANDARD; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 03297d9f8fc..c3d0a897362 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1165,13 +1165,13 @@ if ($id > 0 || !empty($ref)) { if ($action == 'editline' && $lineid == $objp->dispatchlineid) { print '
- + - '; + '; } - print ''; + print ''; if (!empty($conf->reception->enabled)) { print ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 029abf36058..c42bf1c3991 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -8,8 +8,8 @@ * Copyright (C) 2013-2015 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García - * Copyright (C) 2016-2017 Alexandre Spangaro - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2016-2020 Alexandre Spangaro + * Copyright (C) 2018 Frédéric France * Copyright (C) 2019 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -347,6 +347,12 @@ if (empty($reshook)) $result = $object->setBankAccount(GETPOST('fk_account', 'int')); } + // transport mode + if ($action == 'settransportmode' && $user->rights->fournisseur->facture->creer) + { + $result=$object->setTransportMode(GETPOST('transport_mode_id', 'int')); + } + // Set label elseif ($action == 'setlabel' && $usercancreate) { @@ -660,7 +666,8 @@ if (empty($reshook)) $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->transport_mode_id = GETPOST('transport_mode_id', 'int'); // Proprietes particulieres a facture de remplacement $object->fk_facture_source = GETPOST('fac_replacement'); @@ -725,7 +732,8 @@ if (empty($reshook)) $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->transport_mode_id = GETPOST('transport_mode_id', 'int'); // Proprietes particulieres a facture avoir $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; @@ -838,6 +846,7 @@ if (empty($reshook)) $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->transport_mode_id = GETPOST('transport_mode_id'); // Auto calculation of date due if not filled by user if (empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); @@ -1687,6 +1696,7 @@ if ($action == 'create') $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; + $transport_mode_id = (!empty($objectsrc->transport_mode_id) ? $objectsrc->transport_mode_id : (!empty($soc->transport_mode_id) ? $soc->transport_mode_id : 0)); if (!empty($conf->multicurrency->enabled)) { @@ -1705,6 +1715,7 @@ if ($action == 'create') } else { $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; + $transport_mode_id = $societe->transport_mode_supplier_id; $fk_account = $societe->fk_account; $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); @@ -2053,6 +2064,15 @@ if ($action == 'create') print ''; } + // Intracomm report + if (!empty($conf->intracommreport->enabled)) + { + $langs->loadLangs(array("intracommreport")); + print '' . $langs->trans('IntracommReportTransportMode') . ''; + $form->selectModeTransport(isset($_POST['transport_mode_id']) ? $_POST['transport_mode_id'] : $transport_mode_id, 'transport_mode_id'); + print ''; + } + // Public note print ''.$langs->trans('NotePublic').''; print ''; @@ -2109,7 +2129,7 @@ if ($action == 'create') } } - echo ''; + print ''; print ''.$langs->trans('AmountHT').''.price($objectsrc->total_ht).''; print ''.$langs->trans('AmountVAT').''.price($objectsrc->total_tva).""; if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 @@ -2632,6 +2652,26 @@ if ($action == 'create') print ''; } + // Intracomm report + $langs->loadLangs(array("intracommreport")); + print ''; + print ''; + if ($action != 'editmode' && $user->rights->fournisseur->facture->creer) { + print ''; + } + print '
'; + print $langs->trans('IntracommReportTransportMode'); + print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; + print ''; + if ($action == 'editmode') + { + $form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'transport_mode_id', 1, 1); + } + else { + $form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'none'); + } + print ''; + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 8c2fdbdb5b6..bd5950151eb 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -245,7 +245,7 @@ if (empty($reshook)) { $action = 'create'; } - // Le reste propre a cette action s'affiche en bas de page. + // All the next of this action is displayed at the page's bottom. } @@ -292,7 +292,7 @@ if (empty($reshook)) $thirdparty = new Societe($db); if ($socid > 0) $thirdparty->fetch($socid); - // Creation de la ligne paiement + // Creation of payment line $paiement = new PaiementFourn($db); $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array of amounts @@ -521,7 +521,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql .= " WHERE f.entity = ".$conf->entity; $sql .= ' AND f.fk_soc = '.$object->socid; $sql .= ' AND f.paye = 0'; - $sql .= ' AND f.fk_statut = 1'; // Statut=0 => non validee, Statut=2 => annulee + $sql .= ' AND f.fk_statut = 1'; // Status=0 => unvalidated, Status=2 => canceled if ($object->type != FactureFournisseur::TYPE_CREDIT_NOTE) { $sql .= ' AND f.type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation @@ -756,7 +756,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } } - // Bouton Enregistrer + // Save Button if ($action != 'add_paiement') { print '
'.$langs->trans("ClosePaidInvoicesAutomatically"); diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 82c6e1d18d3..7ea1958c9e2 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -128,7 +128,7 @@ if ($action == 'setdatep' && !empty($_POST['datepday'])) // Build document $upload_dir = $conf->fournisseur->payment->dir_output; -// TODO: get the appropriate permisson +// TODO: get the appropriate permission $permissiontoadd = true; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -151,7 +151,7 @@ dol_fiche_head($head, 'payment', $langs->trans('SupplierPayment'), -1, 'payment' if ($result > 0) { /* - * Confirmation de la suppression du paiement + * Confirmation of payment's delete */ if ($action == 'delete') { @@ -159,7 +159,7 @@ if ($result > 0) } /* - * Confirmation de la validation du paiement + * Confirmation of payment's validation */ if ($action == 'valide') { @@ -181,7 +181,7 @@ if ($result > 0) print $form->showrefnav($object,'id','',1,'rowid','ref'); print '';*/ - // Date payment + // Date of payment print ''.$form->editfieldkey("Date", 'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer).''; print $form->editfieldval("Date", 'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer, 'datehourpicker', '', null, $langs->trans('PaymentDateUpdateSucceeded')); print ''; @@ -251,7 +251,7 @@ if ($result > 0) print '
'; /** - * List of vendor invoices + * List of seller's invoices */ $sql = 'SELECT f.rowid, f.rowid as facid, f.ref, f.ref_supplier, f.type, f.paye, f.total_ht, f.total_tva, f.total_ttc, f.datef as date, f.fk_statut as status,'; $sql .= ' pf.amount, s.nom as name, s.rowid as socid'; @@ -332,7 +332,7 @@ if ($result > 0) /* - * Boutons Actions + * Actions Buttons */ print '
'; diff --git a/htdocs/install/mysql/data/llx_c_transport_mode.sql b/htdocs/install/mysql/data/llx_c_transport_mode.sql new file mode 100644 index 00000000000..69f6ac7f6b8 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_transport_mode.sql @@ -0,0 +1,31 @@ +-- Copyright (C) 2019-2020 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 . +-- +-- + +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + + +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('MAR', 'Transport maritime (y compris camions ou wagons sur bateau)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('TRA', 'Transport par chemin de fer (y compris camions sur wagon)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('ROU', 'Transport par route', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('AIR', 'Transport par air', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('POS', 'Envois postaux', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('OLE', 'Installations de transport fixe (oléoduc)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('NAV', 'Transport par navigation intérieure', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('PRO', 'Propulsion propre', 1); diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index b467ca2c535..80e86ae747a 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -103,10 +103,47 @@ ALTER TABLE llx_user DROP COLUMN whatsapp; ALTER TABLE llx_user ADD COLUMN datestartvalidity datetime; ALTER TABLE llx_user ADD COLUMN dateendvalidity datetime; +-- Intracomm Report +CREATE TABLE llx_c_transport_mode ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + code varchar(3) NOT NULL, + label varchar(255) NOT NULL, + active tinyint DEFAULT 1 NOT NULL +) ENGINE=innodb; + +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('MAR', 'Transport maritime (y compris camions ou wagons sur bateau)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('TRA', 'Transport par chemin de fer (y compris camions sur wagon)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('ROU', 'Transport par route', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('AIR', 'Transport par air', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('POS', 'Envois postaux', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('OLE', 'Installations de transport fixe (oléoduc)', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('NAV', 'Transport par navigation intérieure', 1); +INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('PRO', 'Propulsion propre', 1); + +ALTER TABLE llx_facture ADD COLUMN fk_transport_mode integer after location_incoterms; +ALTER TABLE llx_facture_fourn ADD COLUMN fk_transport_mode integer after location_incoterms; + +ALTER TABLE llx_societe ADD COLUMN transport_mode tinyint after cond_reglement; +ALTER TABLE llx_societe ADD COLUMN transport_mode_supplier tinyint after cond_reglement_supplier; + +CREATE TABLE llx_intracommreport +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + + ref varchar(30) NOT NULL, -- report reference number + entity integer DEFAULT 1 NOT NULL, -- multi company id + type_declaration varchar(32), + period varchar(32), + mode varchar(32), + content_xml text, + type_export varchar(10), + datec datetime, + tms timestamp +)ENGINE=innodb; + ALTER TABLE llx_c_incoterms ADD COLUMN label varchar(100) NULL; - - CREATE TABLE llx_recruitment_recruitmentjobposition( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) DEFAULT '(PROV)' NOT NULL, @@ -275,6 +312,7 @@ ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitme ALTER TABLE llx_product MODIFY COLUMN seuil_stock_alerte float; ALTER TABLE llx_product MODIFY COLUMN desiredstock float; + ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN seuil_stock_alerte float; ALTER TABLE llx_product_warehouse_properties MODIFY COLUMN desiredstock float; diff --git a/htdocs/install/mysql/tables/llx_c_transport_mode.key.sql b/htdocs/install/mysql/tables/llx_c_transport_mode.key.sql new file mode 100644 index 00000000000..4a7d5e89009 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_transport_mode.key.sql @@ -0,0 +1,19 @@ +-- =================================================================== +-- 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 . +-- +-- =================================================================== + +ALTER TABLE llx_c_transport_mode ADD UNIQUE INDEX uk_c_transport_mode (code, entity); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_c_transport_mode.sql b/htdocs/install/mysql/tables/llx_c_transport_mode.sql new file mode 100644 index 00000000000..a2634f2a0bf --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_transport_mode.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- 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 . +-- +-- ======================================================================== + +CREATE TABLE llx_c_transport_mode ( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + code varchar(3) NOT NULL, + label varchar(255) NOT NULL, + active tinyint DEFAULT 1 NOT NULL +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 82319a4beef..010cf1c1573 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -86,6 +86,8 @@ create table llx_facture fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms + fk_mode_transport integer, -- for intracomm report + situation_cycle_ref smallint, -- situation cycle reference situation_counter smallint, -- situation counter situation_final smallint, -- is the situation final ? diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index 1d5fdcf13bf..ef7e980b8aa 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -70,6 +70,9 @@ create table llx_facture_fourn note_public text, fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms + + fk_mode_transport integer, -- for intracomm report + model_pdf varchar(255), last_main_doc varchar(255), -- relative filepath+filename of last main generated document diff --git a/htdocs/install/mysql/tables/llx_intracommreport.sql b/htdocs/install/mysql/tables/llx_intracommreport.sql new file mode 100644 index 00000000000..a09396920c7 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_intracommreport.sql @@ -0,0 +1,33 @@ +-- =================================================================== +-- Copyright (C) 2015 ATM Consulting +-- 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 . +-- +-- =================================================================== + +create table llx_intracommreport +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + + ref varchar(30) NOT NULL, -- report reference number + entity integer DEFAULT 1 NOT NULL, -- multi company id + type_declaration varchar(32), + period varchar(32), + mode varchar(32), + content_xml text, + type_export varchar(10), + datec datetime, + tms timestamp +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 88a0fcbda46..ea02b7be8ad 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -92,8 +92,10 @@ create table llx_societe remise_supplier real DEFAULT 0, -- discount by default granted by this supplier mode_reglement tinyint, -- payment mode customer cond_reglement tinyint, -- payment term customer + transport_mode tinyint, -- transport mode customer (Intracomm report) mode_reglement_supplier tinyint, -- payment mode supplier cond_reglement_supplier tinyint, -- payment term supplier + transport_mode_supplier tinyint, -- transport mode supplier (Intracomm report) fk_shipping_method integer, -- preferred shipping method id tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1 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..c2209614a15 --- /dev/null +++ b/htdocs/intracommreport/admin/intracommreport.php @@ -0,0 +1,208 @@ + + * Copyright (C) 2019-2020 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 = GETPOST('action', 'aZ09'); + +// Parameters INTRACOMMREPORT_* and others +$list_DEB = array ( + 'INTRACOMMREPORT_NUM_AGREMENT', +); + +$list_DES = array ( + 'INTRACOMMREPORT_NUM_DECLARATION', +); + +if ($action == 'update') { + $error = 0; + + if (! $error) + { + foreach ($list_DEB as $constname) + { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + foreach ($list_DES as $constname) + { + $constvalue = GETPOST($constname, 'alpha'); + + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + dolibarr_set_const($db, "INTRACOMMREPORT_TYPE_ACTEUR", GETPOST("INTRACOMMREPORT_TYPE_ACTEUR", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INTRACOMMREPORT_ROLE_ACTEUR", GETPOST("INTRACOMMREPORT_ROLE_ACTEUR", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION", GETPOST("INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION", GETPOST("INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "INTRACOMMREPORT_CATEG_FRAISDEPORT", GETPOST("INTRACOMMREPORT_CATEG_FRAISDEPORT", 'alpha'), 'chaine', 0, '', $conf->entity); + + if ($error) { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } + + if (! $error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } +} + +/* + * 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"), -1, "intracommreport"); + +print ''; +print ''; +print ''; + +print_fiche_titre($langs->trans("Parameters").' (DEB)'); + +print ''; +print ''; +print ''; +print ''; +print ''; + +foreach ($list_DEB as $key) +{ + print ''; + + // Param + $label = $langs->trans($key); + print ''; + // Value + print ''; + + print ''; +} + +print ''; +print ''; +$arraychoices=array(''=>$langs->trans("None"), 'PSI'=>'Déclarant pour son compte', 'TDP'=>'Tiers déclarant'); +print ''; +print "\n"; + +print ''; +print ''; +$arraychoices=array(''=>$langs->trans("None"), 'sender'=>'Emetteur', 'PSI'=>'Déclarant'); +print ''; +print "\n"; + +print ''; +print ''; +$arraychoices=array(1=>'Seuil de 460 000 €', 2=>'En dessous de 460 000 €'); +print ''; +print "\n"; + +print ''; +print ''; +$arraychoices=array(3=>'Seuil de 460 000 €', 4=>'En dessous de 460 000 €'); +print ''; +print "\n"; + +print ''; +print ''; +$arraychoices=array(3=>'Seuil de 460 000 €', 4=>'En dessous de 460 000 €'); +print ''; +print "\n"; + +print '
'.$langs->trans("Description").''.$langs->trans("Value").'
'.$label.''; + print ''; + print '
'.$langs->trans("INTRACOMMREPORT_TYPE_ACTEUR").''; +print $form->selectarray('INTRACOMMREPORT_TYPE_ACTEUR', $arraychoices, $conf->global->INTRACOMMREPORT_TYPE_ACTEUR, 0); +print '
'.$langs->trans("INTRACOMMREPORT_ROLE_ACTEUR").''; +print $form->selectarray('INTRACOMMREPORT_ROLE_ACTEUR', $arraychoices, $conf->global->INTRACOMMREPORT_ROLE_ACTEUR, 0); +print '
'.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION").''; +print $form->selectarray('INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION', $arraychoices, $conf->global->INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION, 0); +print '
'.$langs->trans("INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION").''; +print $form->selectarray('INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION', $arraychoices, $conf->global->INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION, 0); +print '
'.$langs->trans("INTRACOMMREPORT_CATEG_FRAISDEPORT").''; +print $formother->select_categories(0, $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT, 'INTRACOMMREPORT_CATEG_FRAISDEPORT'); +print '
'; + + +print_fiche_titre($langs->trans("Parameters").' (DES)'); + +print ''; +print ''; +print ''; +print ''; +print ''; + +foreach ($list_DES as $key) +{ + print ''; + + // Param + $label = $langs->trans($key); + print ''; + // Value + print ''; + + print ''; +} + +print '
'.$langs->trans("Description").''.$langs->trans("Value").'
'.$label.''; + print ''; + print '
'; + +print '
'; +print '
'; +print ''; +print '
'; +print '
'; + +print ''; + +dol_fiche_end(); + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php new file mode 100644 index 00000000000..01cc99574f7 --- /dev/null +++ b/htdocs/intracommreport/card.php @@ -0,0 +1,330 @@ + + * Copyright (C) 2019-2020 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/intracommreport/card.php + * \ingroup Intracomm report + * \brief Page to manage intracomm report export + */ +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/intracommreport/class/intracommreport.class.php'; + +$langs->loadLangs(array("intracommreport")); + +$action = GETPOST('action'); +$exporttype = GETPOST('exporttype'); // DEB ou DES +if (empty($exporttype)) $exporttype = 'deb'; + +$form = new Form($db); +$formother = new FormOther($db); +$year = GETPOST('year'); +$month = GETPOST('month'); +$type_declaration = GETPOST('type'); +$backtopage=GETPOST('backtopage', 'alpha'); + +/* + * Actions + */ + +if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') +{ + $result=$object->delete($id, $user); + if ($result > 0) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + else { + header("Location: list.php"); + exit; + } + } + else { + $errmesg=$object->error; + } +} + +if ($action == 'add' && $user->rights->intracommreport->write) { + $object->label = trim($label); + $object->type = trim($type); + $object->type_declaration = (int) $statut; + $object->subscription = (int) $subscription; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error++; + + if (empty($object->label)) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); + } + else { + $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + } + if ($num) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorLabelAlreadyExists", $login), null, 'errors'); + } + } + + if (! $error) + { + $id=$object->create($user); + if ($id > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create'; + } + } + else { + $action = 'create'; + } +} + +/* + * View + */ + +// Creation mode +if ($action == 'create') +{ + $title = $langs->trans("IntracommReportTitle"); + llxHeader("", $title); + print load_fiche_titre($langs->trans("IntracommReportTitle")); + + print '
'; + print ''; + print ''; + + dol_fiche_head(); + + print ''; + + // Label + print ''; + + // Declaration + $declaration["deb"] = $langs->trans("DEB"); + $declaration["des"] = $langs->trans("DES"); + print '\n"; + + // Analysis period + print ''; + print ''; + print ''; + print ''; + + // Type of declaration + $typeOfDeclaration["introduction"] = $langs->trans("Introduction"); + $typeOfDeclaration["expedition"] = $langs->trans("Expedition"); + print '\n"; + + print '
'.$langs->trans("Label").'
'.$langs->trans("Declaration")."\n"; + print $form->selectarray("declaration", $declaration, GETPOST('declaration', 'alpha')?GETPOST('declaration', 'alpha'):$object->declaration, 0); + print "
'; + print $langs->trans("AnalysisPeriod"); + print ''; + print $formother->select_month($month ? date('M') : $month, 'month', 0, 1, 'widthauto valignmiddle '); + print $formother->select_year($year ? date('Y') : $year, 'year', 0, 3, 3); + print '
'.$langs->trans("TypeOfDeclaration")."\n"; + print $form->selectarray("type_declaration", $typeOfDeclaration, GETPOST('type_declaration', 'alpha')?GETPOST('type_declaration', 'alpha'):$object->type_declaration, 0); + print "
'; + + dol_fiche_end(); + + print '
'; + print '     '; + print '
'; + + print '
'; +} + +if ($id > 0 && $action != 'edit') { + /* ************************************************************************** */ + /* */ + /* View mode */ + /* */ + /* ************************************************************************** */ + $res = $object->fetch($id); + if ($res < 0) { + dol_print_error($db, $object->error); + exit; + } + + /* + * Show tabs + */ + $head = intracommreport_prepare_head($object); + + dol_fiche_head($head, 'general', $langs->trans("IntracommReport"), -1, 'user'); + + // Confirm remove report + if ($action == 'delete') { + $formquestion = array(); + if ($backtopage) { + $formquestion[] = array( + 'type' => 'hidden', + 'name' => 'backtopage', + 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]) + ); + } + print $form->formconfirm("card.php?rowid=" . $id, $langs->trans("DeleteReport"), + $langs->trans("ConfirmDeleteReport"), "confirm_delete", $formquestion, 'no', 1); + } + + $linkback = '' . $langs->trans("BackToList") . ''; + + dol_banner_tab($object, 'rowid', $linkback); + + print '
'; + print '
'; + + print '
'; + print ''; + + // Type + print '\n"; + + // Analysis Period + print ''; + print ''; + + // Type of Declaration + print ''; + print ''; + + print "
' . $langs->trans("Type") . '' . $object->declaration . "
' . $langs->trans("AnalysisPeriod") . '' . $object->period . '
' . $langs->trans("TypeOfDeclaration") . '' . $object->type_declaration . '
\n"; + + print "
\n"; + print '
'; + + dol_fiche_end(); +} + + /* + 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_des() + { + global $langs, $formother, $year, $month, $type_declaration; + + $title = $langs->trans("IntracommReportDESTitle"); + llxHeader("", $title); + print load_fiche_titre($langs->trans("IntracommReportDESTitle")); + + 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 $db, $conf; + + $obj = new TDebProdouane($db); + $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'); + } + */ + +// End of page +llxFooter(); +$db->close(); 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/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php new file mode 100644 index 00000000000..b07d26150d6 --- /dev/null +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -0,0 +1,423 @@ + + * Copyright (C) 2019-2020 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/intracommreport/class/intracommreport.class.php + * \ingroup Intracomm report + * \brief File of class to manage intracomm report + */ +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + +/** + * Class to manage intracomm report + */ +class IntracommReport extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element='intracommreport'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element='intracommreport'; + + /** + * @var int Field with ID of parent key if this field has a parent + */ + public $fk_element='fk_intracommreport'; + + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; + + /** + * DEB - Product + */ + const TYPE_DEB = 0; + + /** + * DES - Service + */ + const TYPE_DES = 1; + + static $type = array( + 'introduction'=>'Introduction' + ,'expedition'=>'Expédition' + ); + + /** + * Constructor + * + * @param DoliDB $db Database handle + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + $this->exporttype = 'deb'; + } + + /** + * Generate XML file + * + * @param int $mode O for create, R for regenerate (Look always 0 ment toujours 0 within the framework of XML exchanges according to documentation) + * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) + * @param string $period_reference Period of reference + * @return void + */ + public function getXML($mode = 'O', $type = 'introduction', $period_reference = '') + { + + global $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->INTRACOMMREPORT_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->INTRACOMMREPORT_TYPE_ACTEUR); + $party->addAttribute('partyRole', $conf->global->INTRACOMMREPORT_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', $period_reference); + if ($conf->global->INTRACOMMREPORT_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->{'INTRACOMMREPORT_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, $period_reference); + /********************************************************************/ + + $this->errors = array_unique($this->errors); + + if (!empty($res)) return $e->asXML(); + else return 0; + } + + /** + * Generate XMLDes file + * + * @param int $period_year Year of declaration + * @param int $period_month Month of declaration + * @param string $type_declaration Declaration type by default - introduction or expedition (always 'expedition' for Des) + * @return void + */ + public function getXMLDes($period_year, $period_month, $type_declaration = 'expedition') + { + global $mysoc; + + $e = new SimpleXMLElement(''); + + $declaration_des = $e->addChild('declaration_des'); + $declaration_des->addChild('num_des', self::getDeclarationNumber($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; + } + + /** + * Add line from invoice + * + * @param int $declaration Reference declaration + * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) + * @param int $period_reference Reference period + * @param string $exporttype deb=DEB, des=DES + * @return int <0 if KO, >0 if OK + */ + public function addItemsFact(&$declaration, $type, $period_reference, $exporttype = 'deb') + { + global $conf; + + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + + $sql = $this->getSQLFactLines($type, $period_reference, $exporttype); + + $resql = $this->db->query($sql); + + if ($resql) { + $i=1; + + if (empty($resql->num_rows)) { + $this->errors[] = 'No data for this period'; + return 0; + } + + if ($exporttype == 'deb' && $conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT > 0) { + $categ_fraisdeport = new Categorie(); + $categ_fraisdeport->fetch($conf->global->INTRACOMMREPORT_CATEG_FRAISDEPORT); + $TLinesFraisDePort = array(); + } + + while ($res = $this->db->fetch_object($resql)) { + if ($exporttype == 'des') + { + $this->addItemXMlDes($declaration, $res, $i); + } else { + if (empty($res->fk_pays)) { + // We don't stop the loop because we want to know all the third parties who don't have an informed country + $this->errors[] = 'Country not filled in for the third party '.$res->nom.''; + } else { + if ($conf->global->INTRACOMMREPORT_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; + } + + /** + * Add invoice line + * + * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) + * @param int $period_reference Reference declaration + * @param string $exporttype deb=DEB, des=DES + * @return int <0 if KO, >0 if OK + */ + public function getSQLFactLines($type, $period_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 "'.$period_reference.'-01" AND "'.$period_reference.'-'.date('t').'"'; + + return $sql; + } + + /** + * Add item for DEB + * + * @param int $declaration Reference declaration + * @param int $res Result of request SQL + * @param int $i Line Id + * @param string $code_douane_spe Specific customs authorities code + * @return void + */ + public function addItemXMl(&$declaration, &$res, $i, $code_douane_spe = '') + { + $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)); + } + + /** + * Add item for DES + * + * @param int $declaration Reference declaration + * @param int $res Result of request SQL + * @param int $i Line Id + * @return void + */ + public function addItemXMlDes($declaration, &$res, $i) + { + $item = $declaration->addChild('ligne_des'); + $item->addChild('numlin_des', $i); + $item->addChild('valeur', round($res->total_ht)); // Total amount excl. tax of the invoice (whole amount expected) + $item->addChild('partner_des', $res->tva_intra); // Represents the foreign customer's VAT number + } + + /** + * This function adds an item by retrieving the customs code of the product with the highest amount in the invoice + * + * @param int $declaration Reference declaration + * @param int $TLinesFraisDePort Data of shipping costs line + * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) + * @param int $categ_fraisdeport Id of category of shipping costs + * @param int $i Line Id + * @return void + */ + public function addItemFraisDePort(&$declaration, &$TLinesFraisDePort, $type, &$categ_fraisdeport, $i) + { + + global $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 = $this->db->query($sql); + $ress = $this->db->fetch_object($resql); + + $this->addItemXMl($declaration, $res, $i, $ress->customcode); + + $i++; + } + } + + /** + * Return next reference of declaration not already used (or last reference) + * + * @return string free ref or last ref + */ + public function getNextDeclarationNumber() + { + $resql = $this->db->query('SELECT MAX(numero_declaration) as max_numero_declaration FROM '.$this->get_table().' WHERE exporttype="'.$this->exporttype.'"'); + if ($resql) $res = $this->db->fetch_object($resql); + + return ($res->max_numero_declaration + 1); + } + + /** + * Verify declaration number. Positive integer of a maximum of 6 characters recommended by the documentation + * + * @param int $number Number to verify / convert + * @return int Number + */ + public static function getDeclarationNumber($number) + { + return str_pad($number, 6, 0, STR_PAD_LEFT); + } + + /** + * Generate XML file + * + * @return void + */ + public 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/index.html b/htdocs/intracommreport/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php new file mode 100644 index 00000000000..6f7ecbc2580 --- /dev/null +++ b/htdocs/intracommreport/list.php @@ -0,0 +1,492 @@ + + * Copyright (C) 2019-2020 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/intracommreport/list.php + * \ingroup Intracomm Report + * \brief Page to list intracomm report + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('intracommreport')); + +$action=GETPOST('action', 'alpha'); +$massaction=GETPOST('massaction', 'alpha'); +$show_files=GETPOST('show_files', 'int'); +$confirm=GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); + +$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$search_ref=GETPOST("search_ref", 'alpha'); +$search_type = GETPOST("search_type", 'int'); +$fourn_id = GETPOST("fourn_id", 'int'); +$catid = GETPOST('catid', 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); +$type=GETPOST("type", "int"); + +$diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id; + +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = (GETPOST("page", 'int')?GETPOST("page", 'int'):0); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield="i.ref"; +if (! $sortorder) $sortorder="ASC"; + +// Initialize context for list +$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'intracommreportlist'; +if ((string) $type == '1') { $contextpage='DESlist'; if ($search_type=='') $search_type='1'; } +if ((string) $type == '0') { $contextpage='DEBlist'; if ($search_type=='') $search_type='0'; } + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$object=new IntracommReport($db); +$hookmanager->initHooks(array('intracommreportlist')); +$extrafields = new ExtraFields($db); +$form=new Form($db); + +/* +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('intracommreport'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +*/ + +if (empty($action)) $action='list'; + +// Get object canvas (By default, this is not defined, so standard usage of dolibarr) +$canvas=GETPOST("canvas"); +$objcanvas=null; +if (! empty($canvas)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; + $objcanvas = new Canvas($db, $action); + $objcanvas->getCanvas('product', 'list', $canvas); +} + +// Security check +/* +if ($search_type=='0') $result=restrictedArea($user, 'produit', '', '', '', '', '', $objcanvas); +elseif ($search_type=='1') $result=restrictedArea($user, 'service', '', '', '', '', '', $objcanvas); +else $result=restrictedArea($user, 'produit|service', '', '', '', '', '', $objcanvas); +*/ + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'i.ref'=>"Ref", + 'pfi.ref_fourn'=>"RefSupplier", + 'i.label'=>"ProductLabel", + 'i.description'=>"Description", + "i.note"=>"Note", +); + +$isInEEC=isInEEC($mysoc); + +// Definition of fields for lists +$arrayfields=array( + 'i.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'i.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'i.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(! empty($conf->produit->enabled) && ! empty($conf->service->enabled))), +); +/* +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) +{ + foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} +*/ +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $sall=""; + $search_ref=""; + $search_label=""; + //$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type. + + $show_childproducts = ''; + $search_array_options=array(); + } + + // Mass actions + $objectclass='Product'; + if ((string) $search_type == '1') { $objectlabel='Services'; } + if ((string) $search_type == '0') { $objectlabel='Products'; } + + $permtoread = $user->rights->produit->lire; + $permtodelete = $user->rights->produit->supprimer; + $uploaddir = $conf->product->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + + +/* + * View + */ +$formother=new FormOther($db); + +$title=$langs->trans('IntracommReportList'.$type); + +$sql = 'SELECT DISTINCT i.rowid, i.type_declaration, i.type_export, i.period, i.mode, i.entity'; +/* +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +} +*/ +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +$sql.= ' FROM '.MAIN_DB_PREFIX.'intracommreport as i'; + +// if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."intracommreport_extrafields as ef on (i.rowid = ef.fk_object)"; + +$sql.= ' WHERE i.entity IN ('.getEntity('intracommreport').')'; + +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +// if the type is not 1, we show all products (type = 0,2,3) +if (dol_strlen($search_type) && $search_type != '-1') +{ + if ($search_type == 1) $sql.= " AND i.type = 1"; + else $sql.= " AND i.type = 0"; +} + +/* +if ($search_ref) $sql .= natural_search('i.ref', $search_ref); +if ($search_label) $sql .= natural_search('i.label', $search_label); +if ($search_barcode) $sql .= natural_search('i.barcode', $search_barcode); +if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell!=-1) $sql.= " AND i.tosell = ".$db->escape($search_tosell); +if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy!=-1) $sql.= " AND i.tobuy = ".$db->escape($search_tobuy); +if (dol_strlen($canvas) > 0) $sql.= " AND i.canvas = '".$db->escape($canvas)."'"; +*/ + +/* +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +*/ +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +$sql.= " GROUP BY i.rowid"; + +/* +// Add fields from extrafields +if (! empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); +} +*/ + +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; + +$sql.= $db->order($sortfield, $sortorder); + +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } +} + +$sql.= $db->plimit($limit + 1, $offset); + +$resql = $db->query($sql); + +if ($resql) +{ + $num = $db->num_rows($resql); + + $arrayofselected=is_array($toselect)?$toselect:array(); + + $helpurl='EN:Module_IntracommReport|FR:Module_ProDouane'; + llxHeader('', $title, $helpurl, ''); + + // Displays product removal confirmation + if (GETPOST('delreport')) { + setEventMessages($langs->trans("IntracommReportDeleted", GETPOST('delreport')), null, 'mesgs'); + } + + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sall) $param.="&sall=".urlencode($sall); + if ($search_ref) $param="&search_ref=".urlencode($search_ref); + if ($search_label) $param.="&search_label=".urlencode($search_label); + + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // List of mass actions available + $arrayofmassactions = array( + 'generate_doc'=>$langs->trans("ReGeneratePDF"), + //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + ); + if ($user->rights->intracommreport->delete) $arrayofmassactions['predelete']="".$langs->trans("Delete"); + if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + $newcardbutton=''; + if ($user->rights->intracommreport->write) + { + $newcardbutton.= dolGetButtonTitle($langs->trans("NewDeclaration"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/intracommreport/card.php?action=create&type='.$type); + } + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (empty($arrayfields['i.fk_product_type']['checked'])) print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); + + $topicmail="Information"; + $modelmail="product"; + $objecttmp=new IntracommReport($db); + $trackid='prod'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if ($sall) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter.=$hookmanager->resPrint; + else $moreforfilter=$hookmanager->resPrint; + + if ($moreforfilter) + { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + + print '
'; + print ''."\n"; + + // Lines with input filters + print ''; + if (! empty($arrayfields['i.ref']['checked'])) + { + print ''; + } + if (! empty($arrayfields['i.label']['checked'])) + { + print ''; + } + // Type + // Type (customer/prospect/supplier) + if (!empty($arrayfields['customerorsupplier']['checked'])) + { + print ''; + } + + if (! empty($arrayfields['i.fk_product_type']['checked'])) + { + print ''; + } + + /* + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + */ + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields); + $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['i.datec']['checked'])) + { + print ''; + } + // Date modification + if (! empty($arrayfields['i.tms']['checked'])) + { + print ''; + } + print ''; + + print ''; + + print ''; + if (! empty($arrayfields['i.ref']['checked'])) { + print_liste_field_titre($arrayfields['i.ref']['label'], $_SERVER["PHP_SELF"], "i.ref", "", $param, "", $sortfield, $sortorder); + } + if (! empty($arrayfields['i.label']['checked'])) { + print_liste_field_titre($arrayfields['i.label']['label'], $_SERVER["PHP_SELF"], "i.label", "", $param, "", $sortfield, $sortorder); + } + if (! empty($arrayfields['i.fk_product_type']['checked'])) { + print_liste_field_titre($arrayfields['i.fk_product_type']['label'], $_SERVER["PHP_SELF"], "i.fk_product_type", "", $param, "", $sortfield, $sortorder); + } + + /* + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + */ + // Hook fields + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); + $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['i.datec']['checked'])) { + print_liste_field_titre($arrayfields['i.datec']['label'], $_SERVER["PHP_SELF"], "i.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (! empty($arrayfields['i.tms']['checked'])) { + print_liste_field_titre($arrayfields['i.tms']['label'], $_SERVER["PHP_SELF"], "i.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print "\n"; + + + $intracommreport_static = new IntracommReport($db); + + $i = 0; + $totalarray=array(); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + $intracommreport_static->id = $obj->rowid; + $intracommreport_static->ref = $obj->ref; + $intracommreport_static->ref_fourn = $obj->ref_supplier; + $intracommreport_static->label = $obj->label; + $intracommreport_static->type = $obj->fk_product_type; + $intracommreport_static->status_buy = $obj->tobuy; + $intracommreport_static->status = $obj->tosell; + $intracommreport_static->status_batch = $obj->tobatch; + $intracommreport_static->entity = $obj->entity; + + print ''; + + // Ref + if (! empty($arrayfields['i.ref']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + // Label + if (! empty($arrayfields['i.label']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Type + if (! empty($arrayfields['i.fk_product_type']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action + print ''; + if (! $i) $totalarray['nbfield']++; + + print "\n"; + $i++; + } + + $db->free($resql); + + print "
'; + print ''; + print ''; + print ''; + print ''; + if ($type != '') print ''; + print $formcompany->selectProspectCustomerType($search_type, 'search_type', 'search_type', 'list'); + print ''; + $array=array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); + print $form->selectarray('search_type', $array, $search_type); + print ''; + print ''; + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
'; + print $intracommreport_static->getNomUrl(1); + print "'.dol_trunc($obj->label, 80).''.$obj->fk_product_type.''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
"; + print "
"; + print '
'; +} +else { + dol_print_error($db); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4e80fc794fb..3091efcf7fd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -978,6 +978,9 @@ Permission63003=Delete resources Permission63004=Link resources to agenda events Permission64001=Allow direct printing Permission67000=Allow printing of receipts +Permission68001=Read intracomm report +Permission68002=Create/modify intracomm report +Permission68004=Delete intracomm report Permission941601=Read receipts Permission941602=Create and modify receipts Permission941603=Validate receipts @@ -1023,6 +1026,7 @@ DictionaryHolidayTypes=Types of leave DictionaryOpportunityStatus=Lead status for project/lead DictionaryExpenseTaxCat=Expense report - Transportation categories DictionaryExpenseTaxRange=Expense report - Range by transportation category +DictionaryTransportMode=Intracomm report - Transport mode SetupSaved=Setup saved SetupNotSaved=Setup not saved BackToModuleList=Back to Module list diff --git a/htdocs/langs/en_US/intracommreport.lang b/htdocs/langs/en_US/intracommreport.lang new file mode 100644 index 00000000000..73a2a22709d --- /dev/null +++ b/htdocs/langs/en_US/intracommreport.lang @@ -0,0 +1,40 @@ +Module68000Name = Intracomm report +Module68000Desc = Intracomm report management (Support for French DEB/DES format) +IntracommReportSetup = Intracommreport module setup +IntracommReportAbout = About intracommreport + +# Setup +INTRACOMMREPORT_NUM_AGREMENT=Numéro d'agrément (délivré par le CISD de rattachement) +INTRACOMMREPORT_TYPE_ACTEUR=Type d'acteur +INTRACOMMREPORT_ROLE_ACTEUR=Rôle joué par l'acteur +INTRACOMMREPORT_NIV_OBLIGATION_INTRODUCTION=Niveau d'obligation sur les introductions +INTRACOMMREPORT_NIV_OBLIGATION_EXPEDITION=Niveau d'obligation sur les expéditions +INTRACOMMREPORT_CATEG_FRAISDEPORT=Catégorie de services de type "Frais de port" + +INTRACOMMREPORT_NUM_DECLARATION=Numéro de déclarant + +# Menu +MenuIntracommReport=Intracomm report +MenuIntracommReportNew=New declaration +MenuIntracommReportList=List + +# View +NewDeclaration=New declaration +Declaration=Declaration +AnalysisPeriod=Analysis period +TypeOfDeclaration=Type of declaration +DEB=Goods exchange declaration (DEB) +DES=Services exchange declaration (DES) + +# Export page +IntracommReportTitle=Preparation of an XML file in ProDouane format + +# List +IntracommReportList=List of generated declarations +IntracommReportNumber=Numéro déclaration +IntracommReportPeriod=Période d'analyse +IntracommReportTypeDeclaration=Type de déclaration +IntracommReportDownload=Télécharger fichier XML + +# Invoice +IntracommReportTransportMode=Transport mode diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 1c4116b34c2..974f758bdc9 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -151,7 +151,7 @@ if (empty($reshook)) } } } else { - header("Location: index.php"); + header("Location: list.php"); exit(); } } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index db38e3c02d7..c7e22bfb5cd 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1183,7 +1183,7 @@ if ($action == 'create' && $user->rights->projet->creer) } /* - * Boutons actions + * Actions Buttons */ print '
'; $parameters = array(); diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 8bbdbed9e6a..471e50139f5 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -84,7 +84,7 @@ if ($action == 'addcontact' && $user->rights->projet->creer) } } -// bascule du statut d'un contact +// Change contact's status if ($action == 'swapstatut' && $user->rights->projet->creer) { if ($object->fetch($id)) @@ -95,7 +95,7 @@ if ($action == 'swapstatut' && $user->rights->projet->creer) } } -// Efface un contact +// Delete a contact if (($action == 'deleteline' || $action == 'deletecontact') && $user->rights->projet->creer) { $object->fetch($id); @@ -128,7 +128,7 @@ $userstatic = new User($db); /* *************************************************************************** */ /* */ -/* Mode vue et edition */ +/* Edition and view mode */ /* */ /* *************************************************************************** */ diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index f15e6d4900f..3ddd0402db7 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -262,14 +262,14 @@ if (count($tasksarray) > 0) $tasks = array(); $task_dependencies = array(); $taskcursor = 0; - foreach ($tasksarray as $key => $val) // Task array are sorted by "project, position, dateo" + foreach ($tasksarray as $key => $val) // Task array are sorted by "project, position, date" { $task->fetch($val->id, ''); $idparent = ($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project); // If start with -, id is a project id $tasks[$taskcursor]['task_id'] = $val->id; - $tasks[$taskcursor]['task_alternate_id'] = ($taskcursor + 1); // An id that has same order than position (requird by ganttchart) + $tasks[$taskcursor]['task_alternate_id'] = ($taskcursor + 1); // An id that has same order than position (required by ganttchart) $tasks[$taskcursor]['task_project_id'] = $val->fk_project; $tasks[$taskcursor]['task_parent'] = $idparent; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 42f84c157a8..1f32494a72c 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -284,7 +284,7 @@ $formproject = new FormProjets($db); $title = $langs->trans("Projects"); -// Get list of project id allowed to user (in a string list separated by coma) +// Get list of project id allowed to user (in a string list separated by comma) $projectsListId = ''; if (!$user->rights->projet->all->lire) $projectsListId = $object->getProjectsAuthorizedForUser($user, 0, 1, $socid); @@ -386,7 +386,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller than paging size (filtering), goto and load page 0 { $page = 0; $offset = 0; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ba16f61f3b2..ac1aa5b8f98 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -464,6 +464,7 @@ class Societe extends CommonObject public $remise_supplier_percent; public $mode_reglement_supplier_id; public $cond_reglement_supplier_id; + public $transport_mode_supplier_id; /** * @var int ID @@ -1307,8 +1308,10 @@ class Societe extends CommonObject $sql .= ",mode_reglement = ".(!empty($this->mode_reglement_id) ? "'".$this->db->escape($this->mode_reglement_id)."'" : "null"); $sql .= ",cond_reglement = ".(!empty($this->cond_reglement_id) ? "'".$this->db->escape($this->cond_reglement_id)."'" : "null"); - $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); + $sql .= ",transport_mode = ".(! empty($this->transport_mode_id) ? "'".$this->db->escape($this->transport_mode_id)."'" : "null"); + $sql .= ",mode_reglement_supplier = ".(!empty($this->mode_reglement_supplier_id) ? "'".$this->db->escape($this->mode_reglement_supplier_id)."'" : "null"); $sql .= ",cond_reglement_supplier = ".(!empty($this->cond_reglement_supplier_id) ? "'".$this->db->escape($this->cond_reglement_supplier_id)."'" : "null"); + $sql .= ",transport_mode_supplier = ".(! empty($this->transport_mode_supplier_id)? "'".$this->db->escape($this->transport_mode_supplier_id)."'" : "null"); $sql .= ",fk_shipping_method = ".(!empty($this->shipping_method_id) ? "'".$this->db->escape($this->shipping_method_id)."'" : "null"); $sql .= ",client = ".(!empty($this->client) ? $this->client : 0); @@ -1646,13 +1649,15 @@ class Societe extends CommonObject $this->remise_supplier_percent = $obj->remise_supplier; $this->mode_reglement_id = $obj->mode_reglement; $this->cond_reglement_id = $obj->cond_reglement; + $this->transport_mode_id = $obj->transport_mode; $this->mode_reglement_supplier_id = $obj->mode_reglement_supplier; $this->cond_reglement_supplier_id = $obj->cond_reglement_supplier; - $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; - $this->fk_account = $obj->fk_account; + $this->transport_mode_supplier_id = $obj->transport_mode_supplier; + $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; + $this->fk_account = $obj->fk_account; - $this->client = $obj->client; - $this->fournisseur = $obj->fournisseur; + $this->client = $obj->client; + $this->fournisseur = $obj->fournisseur; $this->note = $obj->note_private; // TODO Deprecated for backward comtability $this->note_private = $obj->note_private; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 85fb40b0e72..d6c5434ce94 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -510,7 +510,7 @@ form { form#addproduct { padding-top: 10px; } -div.float +div.float, span.floatleft { float:; } 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 diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ecd92c2689c..65afa0e017f 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -632,7 +632,7 @@ form { padding:0px; margin:0px; } -div.float +div.float, span.floatleft { float:; } diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index b819671578c..4326f536f92 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -341,7 +341,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $ok=true; $matches=array(); // Check string name="token" value="'.$_SESSINON - preg_match_all('/name="token" value="\'\.\$_SESSION/', $filecontent, $matches, PREG_SET_ORDER); + preg_match_all('/name="token" value="\'\s*\.\s*\$_SESSION/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if ($file['name'] != 'excludefile.php')