diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 676bbd5bfa5..449a2a73c23 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -96,6 +96,7 @@ class Propal extends CommonObject var $demand_reason_code; var $products=array(); + var $extraparams=array(); var $lines = array(); var $line; @@ -945,25 +946,25 @@ class Propal extends CommonObject { global $conf; - $sql = "SELECT p.rowid,ref,remise,remise_percent,remise_absolue,fk_soc"; - $sql.= ", total, tva, localtax1, localtax2, total_ht"; - $sql.= ", datec"; - $sql.= ", date_valid as datev"; - $sql.= ", datep as dp"; - $sql.= ", fin_validite as dfv"; - $sql.= ", date_livraison as date_livraison"; - $sql.= ", ca.code as availability_code, ca.label as availability"; - $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; - $sql.= ", model_pdf, ref_client"; - $sql.= ", note as note_private, note_public"; - $sql.= ", fk_projet, fk_statut"; - $sql.= ", fk_user_author, fk_user_valid, fk_user_cloture"; - $sql.= ", fk_adresse_livraison"; + $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; + $sql.= ", p.datec"; + $sql.= ", p.date_valid as datev"; + $sql.= ", p.datep as dp"; + $sql.= ", p.fin_validite as dfv"; + $sql.= ", p.date_livraison as date_livraison"; + $sql.= ", p.model_pdf, p.ref_client, p.extraparams"; + $sql.= ", p.note as note_private, p.note_public"; + $sql.= ", p.fk_projet, p.fk_statut"; + $sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture"; + $sql.= ", p.fk_adresse_livraison"; $sql.= ", p.fk_availability"; $sql.= ", p.fk_demand_reason"; $sql.= ", p.fk_cond_reglement"; $sql.= ", p.fk_mode_reglement"; $sql.= ", c.label as statut_label"; + $sql.= ", ca.code as availability_code, ca.label as availability"; + $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; @@ -1023,13 +1024,15 @@ class Propal extends CommonObject $this->fk_delivery_address = $obj->fk_adresse_livraison; // TODO obsolete $this->fk_address = $obj->fk_adresse_livraison; - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->mode_reglement_code = $obj->mode_reglement_code; - $this->mode_reglement = $obj->mode_reglement; - $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement; - $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement; + $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc; + + $this->extraparams = (array) dol_json_decode($obj->extraparams, true); $this->user_author_id = $obj->fk_user_author; $this->user_valid_id = $obj->fk_user_valid; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 87274fc46fe..6e7ef80e739 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -86,6 +86,7 @@ class Commande extends CommonObject var $note; // deprecated var $note_private; var $note_public; + var $extraparams=array(); var $origin; var $origin_id; @@ -1224,7 +1225,7 @@ class Commande extends CommonObject $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as facturee'; - $sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison'; + $sql.= ', c.note as note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_adresse_livraison, c.extraparams'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc'; $sql.= ', ca.code as availability_code'; @@ -1288,6 +1289,8 @@ class Commande extends CommonObject $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->fk_delivery_address = $obj->fk_adresse_livraison; $this->propale_id = $obj->fk_source; + + $this->extraparams = (array) dol_json_decode($obj->extraparams, true); $this->lines = array(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d6765742f7e..5e5bc8892f4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -102,6 +102,7 @@ class Facture extends CommonObject var $products=array(); // deprecated var $lines=array(); var $line; + var $extraparams=array(); //! Pour board var $nbtodo; var $nbtodolate; @@ -766,7 +767,7 @@ class Facture extends CommonObject $sql.= ', f.tms as datem'; $sql.= ', f.note as note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf'; $sql.= ', f.fk_facture_source'; - $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet'; + $sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams'; $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; $sql.= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; @@ -825,6 +826,8 @@ class Facture extends CommonObject $this->user_author = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->modelpdf = $obj->model_pdf; + + $this->extraparams = (array) dol_json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php new file mode 100644 index 00000000000..484f8165723 --- /dev/null +++ b/htdocs/core/ajax/extraparams.php @@ -0,0 +1,70 @@ + + * + * 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 2 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/ajax/showhide.php + * \brief File to return Ajax response on set show/hide element + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +include("../../main.inc.php"); + +$id = GETPOST('id','int'); +$element = GETPOST('element','alpha'); +$htmlelement = GETPOST('htmlelement','alpha'); +$type = GETPOST('type', 'alpha'); + +/* + * View + */ + +top_httphead(); + +print ''."\n"; + +// Registering the location of boxes +if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) +{ + $value = GETPOST('value','alpha'); + $params=array(); + + dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); + + // For compatibility + if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + if ($element == 'facture') { $element = 'compta/facture'; $subelement = 'facture'; } + if ($element == 'contract') { $element = $subelement = 'contrat'; } + if ($element == 'shipping') { $element = $subelement = 'expedition'; } + + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + + $classname = ucfirst($subelement); + $object = new $classname($db); + $object->id = $id; + + $params[$htmlelement] = array($type => $value); + $result=$object->setExtraParameters($params); +} + +?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ef21b9a7aa0..c89fe9aba22 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2127,6 +2127,38 @@ abstract class CommonObject dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies'); return $nb; } + + /** + * Set extra parameters + * + * @param array $params Extra parameters + */ + function setExtraParameters($params) + { + $this->db->begin(); + + $this->extraparams = array_merge($this->extraparams, (array) $params); + + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; + $sql.= ' SET extraparams = "'.$this->db->escape(dol_json_encode($this->extraparams)).'"'; + $sql.= ' WHERE rowid = '.$this->id; + + dol_syslog(get_class($this)."::setExtraParameters sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::setExtraParameters ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return 1; + } + } + // -------------------- // TODO: All functions here must be redesigned and moved as they are not business functions but output functions diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 7caa1ee1495..ee730e24350 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -16,6 +16,7 @@ * */ +$hide = $object->extraparams['notes']['showhide']; $module = $object->element; if ($module == 'propal') $module = 'propale'; @@ -38,14 +39,17 @@ $(document).ready(function() { $("#hide-notes").show(); }); function setShowHide(status) { - var id = id; ?>; - var element = 'element; ?>'; - //$.get("?id="+id+"&element="+element+"&status="+status); + var id = id; ?>; + var element = 'element; ?>'; + var htmlelement = 'notes'; + var type = 'showhide'; + + $.get("?id="+id+"&element="+element+"&htmlelement="+htmlelement+"&type="+type+"&value="+status); } }); - +
diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index 193bcfd22b1..ee814704d27 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -434,4 +434,10 @@ ALTER TABLE llx_product_fournisseur_price DROP INDEX idx_product_fournisseur_pri --ALTER TABLE llx_product_fournisseur_price DROP COLUMN fk_product_fournisseur; ALTER TABLE llx_product_fournisseur_price ADD COLUMN tva_tx double(6,3) NOT NULL DEFAULT 0 AFTER unitprice; -UPDATE llx_c_departements SET ncc='JUJUY', nom = 'Jujuy' WHERE code_departement='2302' and fk_region='2301'; \ No newline at end of file +UPDATE llx_c_departements SET ncc='JUJUY', nom = 'Jujuy' WHERE code_departement='2302' and fk_region='2301'; + +ALTER TABLE llx_propal ADD COLUMN import_key varchar(14) AFTER fk_demand_reason; +ALTER TABLE llx_propal ADD COLUMN extraparams varchar(255) AFTER import_key; +ALTER TABLE llx_commande ADD COLUMN extraparams varchar(255) AFTER import_key; +ALTER TABLE llx_facture ADD COLUMN extraparams varchar(255) AFTER import_key; + diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 826c6dd9b9a..86fa9b19964 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -64,6 +64,7 @@ create table llx_commande fk_availability integer NULL, fk_demand_reason integer, -- should be named fk_input_reason fk_adresse_livraison integer, -- delivery address (deprecated) - import_key varchar(14) + import_key varchar(14), + extraparams varchar(255) -- for stock other parameters with json format )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index 040e10c1f6a..9d1663d0a0d 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -70,6 +70,7 @@ create table llx_facture note text, note_public text, model_pdf varchar(255), - import_key varchar(14) + import_key varchar(14), + extraparams varchar(255) -- for stock other parameters with json format )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index 6379fe101b6..26aee3ff99c 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -63,5 +63,8 @@ create table llx_propal date_livraison date DEFAULT NULL, -- delivery date fk_availability integer NULL, fk_demand_reason integer, + import_key varchar(14), + extraparams varchar(255), -- for stock other parameters with json format fk_adresse_livraison integer -- delivery address (deprecated) + )ENGINE=innodb;