diff --git a/ChangeLog b/ChangeLog index 32bb738eba6..0164ca14788 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,15 +8,19 @@ For users: - New: [ task #867 ] Remove ESAEB external module code from core. - New: Can create proposal from an intervention. - New: Can filter events on a group of users. -- New: Add thirdparty to filter on events. +- New: Can filter events of a thirdparty. +- New: Split Agenda view (month, week, day) into different tabs. - New: Form to add a photo is immediatly available on photo page if permissions are ok (save one click per photo to add). - New: Add option PRODUCT_MAX_VISIBLE_PHOTO to limit number of photos shown on main product card. - New: Add event FICHINTER_CLASSIFY_BILLED into list of possible events to create an automatic event into agenda. -- New: Add new type of event (when type of events are used, not by - default) +- New: Add new type of event (when type of events are used, not by default) +- New: Add country into table of thirdparties type. This will allow to provide + a list of thirdparty types specific to a country (like argentina that + need type A or B). +- New: Can force a specific bank account onto an invoice/order... - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1470, #1472, #1473] User trigger problem - Fix: [ bug #1489, #1491 ] Intervention trigger problem diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 656158a19cd..788483196e4 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -130,16 +130,16 @@ $tablib[24]= "DictionaryAccountancysystem"; $tablib[25]= "DictionaryRevenueStamp"; $tablib[26]= "DictionaryResourceType"; -// Requete pour extraction des donnees des dictionnaires +// Requests to extract data $tabsql=array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as country_code, p.libelle as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, p.code as country_code, p.libelle as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid and r.active=1 and p.active=1"; -$tabsql[3] = "SELECT r.rowid as rowid, code_region as code, nom as libelle, r.fk_pays as country_id, p.code as country_code, p.libelle as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE r.fk_pays=p.rowid and p.active=1"; +$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, p.code as country_code, p.libelle as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE r.fk_pays=p.rowid and p.active=1"; $tabsql[4] = "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_pays"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.civilite AS libelle, c.active FROM ".MAIN_DB_PREFIX."c_civilite AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; $tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, p.code as country_code, p.libelle as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1"; -$tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent"; +$tabsql[8] = "SELECT t.id as rowid, t.code as code, t.libelle, t.fk_country as country_id, p.code as country_code, p.libelle as country, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON t.fk_country=p.rowid"; $tabsql[9] = "SELECT code_iso as code, label, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies"; $tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, p.libelle as country, p.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid"; $tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t"; @@ -159,7 +159,7 @@ $tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, p.c $tabsql[25]= "SELECT t.rowid, t.taux, p.libelle as country, p.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid"; $tabsql[26]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -// Critere de tri du dictionnaire +// Criteria to sort dictionaries $tabsqlsort=array(); $tabsqlsort[1] ="country ASC, code ASC"; $tabsqlsort[2] ="country ASC, code ASC"; @@ -168,7 +168,7 @@ $tabsqlsort[4] ="code ASC"; $tabsqlsort[5] ="libelle ASC"; $tabsqlsort[6] ="a.type ASC, a.module ASC, a.position ASC, a.code ASC"; $tabsqlsort[7] ="country ASC, code ASC, a.libelle ASC"; -$tabsqlsort[8] ="libelle ASC"; +$tabsqlsort[8] ="country DESC, libelle ASC"; $tabsqlsort[9] ="label ASC"; $tabsqlsort[10]="country ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC"; $tabsqlsort[11]="element ASC, source ASC, code ASC"; @@ -197,7 +197,7 @@ $tabfield[4] = "code,libelle"; $tabfield[5] = "code,libelle"; $tabfield[6] = "code,libelle,type,position"; $tabfield[7] = "code,libelle,country_id,country,accountancy_code,deductible"; -$tabfield[8] = "code,libelle"; +$tabfield[8] = "code,libelle,country_id,country"; $tabfield[9] = "code,label,unicode"; $tabfield[10]= "country_id,country,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[11]= "element,source,code,libelle"; @@ -226,7 +226,7 @@ $tabfieldvalue[4] = "code,libelle"; $tabfieldvalue[5] = "code,libelle"; $tabfieldvalue[6] = "code,libelle,type,position"; $tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible"; -$tabfieldvalue[8] = "code,libelle"; +$tabfieldvalue[8] = "code,libelle,country"; $tabfieldvalue[9] = "code,label,unicode"; $tabfieldvalue[10]= "country,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[11]= "element,source,code,libelle"; @@ -255,7 +255,7 @@ $tabfieldinsert[4] = "code,libelle"; $tabfieldinsert[5] = "code,civilite"; $tabfieldinsert[6] = "code,libelle,type,position"; $tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible"; -$tabfieldinsert[8] = "code,libelle"; +$tabfieldinsert[8] = "code,libelle,fk_country"; $tabfieldinsert[9] = "code_iso,label,unicode"; $tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[11]= "element,source,code,libelle"; @@ -428,7 +428,8 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=1; foreach ($listfield as $f => $value) { - if ($value == 'country' && in_array('region_id',$listfield)) continue; // For region page, we do not require the country input + if ($value == 'country' && in_array($tablib[$id],array('DictionaryRegion','DictionaryCompanyType'))) continue; // For some pages, country is not mandatory + if ($value == 'country_id' && in_array($tablib[$id],array('DictionaryRegion','DictionaryCompanyType'))) continue; // For some pages, country is not mandatory if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; if ((! isset($_POST[$value]) || $_POST[$value]=='') @@ -473,9 +474,17 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } - if (isset($_POST["country"]) && $_POST["country"]=='0') { - $ok=0; - setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")),'errors'); + if (isset($_POST["country"]) && $_POST["country"]=='0') + { + if (in_array($tablib[$id],array('DictionaryCompanyType'))) + { + $_POST["country"]=''; + } + else + { + $ok=0; + setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")),'errors'); + } } // Clean some parameters diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index dd039b71015..eea64ed10ac 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -156,7 +156,8 @@ class Ctypent // extends CommonObject $sql = "SELECT"; $sql.= " t.id,"; $sql.= " t.code,"; - $sql.= " t.libelle,"; + $sql.= " t.libelle as label,"; + $sql.= " t.fk_country as country_id,"; $sql.= " t.active,"; $sql.= " t.module"; $sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t"; @@ -173,7 +174,8 @@ class Ctypent // extends CommonObject $this->id = $obj->id; $this->code = $obj->code; - $this->libelle = $obj->libelle; + $this->libelle = $obj->label; + $this->country_id = $obj->country_id; $this->active = $obj->active; $this->module = $obj->module; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index d71c26af29c..7728080c01b 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -57,13 +57,13 @@ class FormCompany */ function typent_array($mode=0, $filter='') { - global $langs; + global $langs,$mysoc; $effs = array(); $sql = "SELECT id, code, libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; - $sql.= " WHERE active = 1"; + $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; if ($filter) $sql.=" ".$filter; $sql.= " ORDER by id"; dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); diff --git a/htdocs/install/mysql/data/llx_c_typent.sql b/htdocs/install/mysql/data/llx_c_typent.sql index 154798cdd4f..8349cd13a5a 100644 --- a/htdocs/install/mysql/data/llx_c_typent.sql +++ b/htdocs/install/mysql/data/llx_c_typent.sql @@ -27,17 +27,19 @@ -- -- --- Types entreprises +-- Types of thirdparties -- delete from llx_c_typent; -insert into llx_c_typent (id,code,libelle,active) values ( 0, 'TE_UNKNOWN', '-', 1); -insert into llx_c_typent (id,code,libelle,active) values ( 1, 'TE_STARTUP', 'Start-up', 0); -insert into llx_c_typent (id,code,libelle,active) values ( 2, 'TE_GROUP', 'Grand groupe', 1); -insert into llx_c_typent (id,code,libelle,active) values ( 3, 'TE_MEDIUM', 'PME/PMI', 1); -insert into llx_c_typent (id,code,libelle,active) values ( 4, 'TE_SMALL', 'TPE', 1); -insert into llx_c_typent (id,code,libelle,active) values ( 5, 'TE_ADMIN', 'Administration',1); -insert into llx_c_typent (id,code,libelle,active) values ( 6, 'TE_WHOLE', 'Grossiste', 0); -insert into llx_c_typent (id,code,libelle,active) values ( 7, 'TE_RETAIL', 'Revendeur', 0); -insert into llx_c_typent (id,code,libelle,active) values ( 8, 'TE_PRIVATE', 'Particulier', 1); -insert into llx_c_typent (id,code,libelle,active) values (100, 'TE_OTHER', 'Autres', 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 0, 'TE_UNKNOWN', '-', NULL, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 1, 'TE_STARTUP', 'Start-up', NULL, 0); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 2, 'TE_GROUP', 'Grand groupe', NULL, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 3, 'TE_MEDIUM', 'PME/PMI', NULL, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 4, 'TE_SMALL', 'TPE', NULL, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 5, 'TE_ADMIN', 'Administration',NULL, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 6, 'TE_WHOLE', 'Grossiste', NULL, 0); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 7, 'TE_RETAIL', 'Revendeur', NULL, 0); +insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 8, 'TE_PRIVATE', 'Particulier', NULL, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values (100, 'TE_OTHER', 'Autres', NULL, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values (231, 'TE_A1', 'Type A', 23, 1); +insert into llx_c_typent (id,code,libelle,fk_country,active) values (232, 'TE_B2', 'Type B', 23, 1); diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 19b820d964c..f6de3ef3b03 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -21,10 +21,15 @@ ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER active; -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (29,'FICHINTER_CLASSIFY_BILLED','Classify intervention as billed','Executed when a intervention is classified as billed (when option FICHINTER_DISABLE_DETAILS is set)','ficheinter',19); +-- Defined only to have specific list for countries that can't use generic list (like argentina that need type A or B) +ALTER TABLE llx_c_typent ADD COLUMN fk_country integer NULL AFTER libelle; + +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (29,'FICHINTER_CLASSIFY_BILLED','Classify intervention as billed','Executed when a intervention is classified as billed (when option FICHINTER_DISABLE_DETAILS is set)','ficheinter',19); -insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values (11,'AC_INT','system','Intervention on site',NULL, 1, 4); +INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, active, position) values (11,'AC_INT','system','Intervention on site',NULL, 1, 4); + + ALTER TABLE llx_accountingaccount add column entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_accountingaccount add column datec datetime NOT NULL AFTER entity; ALTER TABLE llx_accountingaccount add column tms timestamp AFTER datec; diff --git a/htdocs/install/mysql/tables/llx_c_typent.sql b/htdocs/install/mysql/tables/llx_c_typent.sql index 62d39cea8ad..06a41727b69 100644 --- a/htdocs/install/mysql/tables/llx_c_typent.sql +++ b/htdocs/install/mysql/tables/llx_c_typent.sql @@ -19,9 +19,10 @@ create table llx_c_typent ( - id integer PRIMARY KEY, - code varchar(12) NOT NULL, - libelle varchar(30), - active tinyint DEFAULT 1 NOT NULL, - module varchar(32) NULL + id integer PRIMARY KEY, + code varchar(12) NOT NULL, + libelle varchar(30), + fk_country integer NULL, -- Defined only to have specific list for countries that can't use generic list (like argentina that need type A or B) + active tinyint DEFAULT 1 NOT NULL, + module varchar(32) NULL )ENGINE=innodb;