From 8f8dce19cc53aabec53f8cf0de10f69c99bdd5ec Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 15 Apr 2013 12:38:27 +0200 Subject: [PATCH 1/4] Task Project Extrafield : Forget to add to index tables --- .../tables/llx_projet_extrafields.key.sql | 20 ++++++++++++++ .../mysql/tables/llx_projet_extrafields.sql | 26 +++++++++++++++++++ .../llx_projet_task_extrafields.key.sql | 20 ++++++++++++++ .../tables/llx_projet_task_extrafields.sql | 26 +++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100755 htdocs/install/mysql/tables/llx_projet_extrafields.key.sql create mode 100755 htdocs/install/mysql/tables/llx_projet_extrafields.sql create mode 100755 htdocs/install/mysql/tables/llx_projet_task_extrafields.key.sql create mode 100755 htdocs/install/mysql/tables/llx_projet_task_extrafields.sql diff --git a/htdocs/install/mysql/tables/llx_projet_extrafields.key.sql b/htdocs/install/mysql/tables/llx_projet_extrafields.key.sql new file mode 100755 index 00000000000..d756f96472b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_projet_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2013 Florian Henry +-- +-- 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_projet_extrafields ADD INDEX idx_projet_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_projet_extrafields.sql b/htdocs/install/mysql/tables/llx_projet_extrafields.sql new file mode 100755 index 00000000000..ae1689a56f1 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_projet_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2013 Florian Henry +-- +-- 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_projet_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_projet_task_extrafields.key.sql b/htdocs/install/mysql/tables/llx_projet_task_extrafields.key.sql new file mode 100755 index 00000000000..6ff72738530 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_projet_task_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2013 Florian Henry +-- +-- 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_projet_task_extrafields ADD INDEX idx_projet_task_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_projet_task_extrafields.sql b/htdocs/install/mysql/tables/llx_projet_task_extrafields.sql new file mode 100755 index 00000000000..62831113c6a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_projet_task_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2013 Florian Henry +-- +-- 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_projet_task_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + From 882560dad7121bad947c5586c09347fb42b25844 Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 15 Apr 2013 14:34:32 +0200 Subject: [PATCH 2/4] Fix [ bug #821 ] 'f.facnumber' in accountancy --- htdocs/compta/journal/purchasesjournal.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index f24ad4c3837..a37d5c240df 100755 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -95,7 +95,7 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $p[0]; -$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.libelle,"; +$sql = "SELECT f.rowid, f.ref_supplier, f.type, f.datef, f.libelle,"; $sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,"; $sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,"; @@ -146,7 +146,7 @@ if ($result) $compta_localtax2 = (! empty($obj->account_localtax2)?$obj->account_localtax2:$langs->trans("CodeNotDef")); $tabfac[$obj->rowid]["date"] = $obj->datef; - $tabfac[$obj->rowid]["ref"] = $obj->facnumber; + $tabfac[$obj->rowid]["ref"] = $obj->ref_supplier; $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["lib"] = $obj->libelle; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; From acd3d136b545a6bd5c513dd5b824f0d9ad0705df Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 15 Apr 2013 15:31:12 +0200 Subject: [PATCH 3/4] [ task #798 ] Add range limit date on product/services as it is done on order and invoice --- htdocs/comm/propal.php | 24 +++++++++----- htdocs/comm/propal/class/propal.class.php | 38 +++++++++++++++++++---- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 9c77da67765..6090e909920 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -8,7 +8,7 @@ * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Florian Henry * * 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 @@ -661,7 +661,7 @@ else if ($action == "addline" && $user->rights->propal->creer) $pu_ttc=0; $price_min=0; $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); - + // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit @@ -768,6 +768,9 @@ else if ($action == "addline" && $user->rights->propal->creer) // Margin $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + + $date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $object->client); @@ -803,7 +806,9 @@ else if ($action == "addline" && $user->rights->propal->creer) GETPOST('fk_parent_line'), $fournprice, $buyingprice, - $label + $label, + $date_start, + $date_end ); if ($result > 0) @@ -868,6 +873,9 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + $date_start=dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + // Define special_code for special lines $special_code=0; if (! GETPOST('qty')) $special_code=3; @@ -924,7 +932,9 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa $fournprice, $buyingprice, $label, - $type + $type, + $date_start, + $date_end ); if ($result >= 0) @@ -1967,18 +1977,18 @@ else if ($conf->global->MAIN_FEATURES_LEVEL > 1) { // Add free or predefined products/services - $object->formAddObjectLine(0,$mysoc,$soc); + $object->formAddObjectLine(1,$mysoc,$soc); } else { // Add free products/services - $object->formAddFreeProduct(0,$mysoc,$soc); + $object->formAddFreeProduct(1,$mysoc,$soc); // Add predefined products/services if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $var=!$var; - $object->formAddPredefinedProduct(0,$mysoc,$soc); + $object->formAddPredefinedProduct(1,$mysoc,$soc); } } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1c514dd679a..1b283e41ed0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -307,11 +307,13 @@ class Propal extends CommonObject * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price without tax * @param string $label ??? + * @param timestamp $date_start Start date of the line + * @param timestamp $date_end End date of the line * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='') + function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$date_start='', $date_end='') { global $conf; @@ -401,6 +403,9 @@ class Propal extends CommonObject $this->line->product_type=$type; $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; + + $this->line->date_start=$date_start; + $this->line->date_end=$date_end; // infos marge $this->line->fk_fournprice = $fk_fournprice; @@ -465,9 +470,11 @@ class Propal extends CommonObject * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label ??? * @param int $type 0/1=Product/service + * @param timestamp $date_start Start date of the line + * @param timestamp $date_end End date of the line * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $type=0) + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='') { global $conf,$user,$langs; @@ -545,6 +552,9 @@ class Propal extends CommonObject // infos marge $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + + $this->line->date_start=$date_start; + $this->line->date_end=$date_end; // TODO deprecated $this->line->price=$price; @@ -1098,7 +1108,8 @@ class Propal extends CommonObject */ $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; - $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label'; + $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; + $sql.= ' d.date_start, d.date_end'; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= " WHERE d.fk_propal = ".$this->id; @@ -1153,6 +1164,9 @@ class Propal extends CommonObject $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; + + $line->date_start = $objp->date_start; + $line->date_end = $objp->date_end; $this->lines[$i] = $line; //dol_syslog("1 ".$line->fk_product); @@ -2626,6 +2640,9 @@ class PropaleLigne var $localtax2_tx; var $total_localtax1; var $total_localtax2; + + var $date_start; + var $date_end; var $skip_update_total; // Skip update price total for special lines @@ -2651,7 +2668,8 @@ class PropaleLigne $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc'; + $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; + $sql.= ' pd.date_start, pd.date_end'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; $sql.= ' WHERE pd.rowid = '.$rowid; @@ -2695,6 +2713,9 @@ class PropaleLigne $this->libelle = $objp->product_label; // deprecated $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; + + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); $this->db->free($result); } @@ -2749,7 +2770,8 @@ class PropaleLigne $sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; - $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang)'; + $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; + $sql.= ' date_start, date_end)'; $sql.= " VALUES (".$this->fk_propal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -2772,7 +2794,9 @@ class PropaleLigne $sql.= " ".(isset($this->fk_fournprice)?"'".$this->fk_fournprice."'":"null").","; $sql.= " ".(isset($this->pa_ht)?"'".price2num($this->pa_ht)."'":"null").","; $sql.= ' '.$this->special_code.','; - $sql.= ' '.$this->rang; + $sql.= ' '.$this->rang.','; + $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").','; + $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); $sql.= ')'; dol_syslog(get_class($this).'::insert sql='.$sql, LOG_DEBUG); @@ -2904,6 +2928,8 @@ class PropaleLigne if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; + $sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null"); + $sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null"); $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); From 24a6321d45e9af6210b51aa9081f4825e76c4e45 Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 15 Apr 2013 15:55:10 +0200 Subject: [PATCH 4/4] Fix : Add service date limit transfert from propal to order --- htdocs/commande/class/commande.class.php | 3 +++ htdocs/commande/fiche.php | 4 ++-- htdocs/core/class/commonobject.class.php | 29 +++++++++++++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b6e11a64065..4612d378908 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -933,6 +933,9 @@ class Commande extends CommonOrder $line->rang = $object->lines[$i]->rang; $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + + $line->date_start = $object->lines[$i]->date_start; + $line->date_end = $object->lines[$i]->date_end; $line->fk_fournprice = $object->lines[$i]->fk_fournprice; $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 150a55923dd..350051705d2 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -329,8 +329,8 @@ else if ($action == 'add' && $user->rights->commande->creer) $lines[$i]->fk_remise_except, 'HT', 0, - $datestart, - $dateend, + $date_start, + $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 124447bb81c..8d2d4a4f5d6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2930,11 +2930,24 @@ abstract class CommonObject global $conf,$langs,$bc; //var_dump($line); - - $date_start=$line->date_debut_prevue; - if ($line->date_debut_reel) $date_start=$line->date_debut_reel; - $date_end=$line->date_fin_prevue; - if ($line->date_fin_reel) $date_end=$line->date_fin_reel; + if (!empty($line->date_start)) + { + $date_start=$line->date_start; + } + else + { + $date_start=$line->date_debut_prevue; + if ($line->date_debut_reel) $date_start=$line->date_debut_reel; + } + if (!empty($line->date_end)) + { + $date_end=$line->date_end; + } + else + { + $date_end=$line->date_fin_prevue; + if ($line->date_fin_reel) $date_end=$line->date_fin_reel; + } $this->tpl['label'] = ''; if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow'); @@ -2962,7 +2975,11 @@ abstract class CommonObject else { $this->tpl['label'].= ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product'))); - $this->tpl['label'].= ($line->label ? ' '.$line->label : ''); + if (!empty($line->desc)) { + $this->tpl['label'].=$line->desc; + }else { + $this->tpl['label'].= ($line->label ? ' '.$line->label : ''); + } // Dates if ($line->product_type == 1 && ($date_start || $date_end)) {