From db54b6f596ba80d06740885e1baab5e8fc53bc72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 20 Jul 2015 11:19:40 +0200 Subject: [PATCH 1/9] Fix: [ bug #3198 ] Trigger LINECONTRACT_INSERT passes Contrat as $object instead of ContratLigne Created new ContratLigne::insert function Close #3198 --- ChangeLog | 3 + htdocs/contrat/class/contrat.class.php | 160 ++++++++++++++++--------- 2 files changed, 107 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index afae634dfb3..56e04ded436 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,9 @@ FIX [ bug #2900 ] Courtesy title is not stored in create thirdparty form FIX [ bug #3055 ] Product image thumbnails were not deleted after deleting the image FIX [ bug 1634 ] Error deleting a project when it had many linked objects FIX [ bug 1925 ] "Link to order" option in supplier invoices is not working properly +FIX [ bug #3198 ] Trigger LINECONTRACT_INSERT passes Contrat as $object instead of ContratLigne + +NEW: Created new ContratLigne::insert function ***** ChangeLog for 3.7.1 compared to 3.7.* ***** FIX Bug in the new photo system diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 76a01b9f0c8..d2e066082d0 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Florian Henry - * Copyright (C) 2014 Marcos García + * Copyright (C) 2014-2015 Marcos García * * 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 @@ -1312,67 +1312,48 @@ class Contrat extends CommonObject $pa_ht = $pu_ht * (1 - $remise_percent / 100); } - // Insertion dans la base - $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; - $sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,"; - $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; - $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; - $sql.= " info_bits,"; - $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; - if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; } - if ($date_end > 0) { $sql.= ",date_fin_validite"; } - $sql.= ") VALUES ($this->id, '', '" . $this->db->escape($desc) . "',"; - $sql.= ($fk_product>0 ? $fk_product : "null").","; - $sql.= " '".$qty."',"; - $sql.= " '".$txtva."',"; - $sql.= " '".$txlocaltax1."',"; - $sql.= " '".$txlocaltax2."',"; - $sql.= " '".$localtax1_type."',"; - $sql.= " '".$localtax2_type."',"; - $sql.= " ".price2num($remise_percent).",".price2num($pu_ht).","; - $sql.= " ".price2num($total_ht).",".price2num($total_tva).",".price2num($total_localtax1).",".price2num($total_localtax2).",".price2num($total_ttc).","; - $sql.= " '".$info_bits."',"; - $sql.= " ".price2num($price).",".price2num($remise).","; - if (isset($fk_fournprice)) $sql.= ' '.$fk_fournprice.','; - else $sql.= ' null,'; - if (isset($pa_ht)) $sql.= ' '.price2num($pa_ht); - else $sql.= ' null'; - if ($date_start > 0) { $sql.= ",'".$this->db->idate($date_start)."'"; } - if ($date_end > 0) { $sql.= ",'".$this->db->idate($date_end)."'"; } - $sql.= ")"; + $line = new ContratLigne($this->db); - dol_syslog(get_class($this)."::addline", LOG_DEBUG); + $line->fk_contrat = $this->id; + $line->label = $desc; + $line->description = $desc; + $line->fk_product = $fk_product; + $line->qty = $qty; + $line->tva_tx = $txtva; + $line->localtax1_tx = $txlocaltax1; + $line->localtax2_tx = $txlocaltax2; + $line->localtax1_type = $localtax1_type; + $line->localtax2_type = $localtax2_type; + $line->remise_percent = $remise_percent; + $line->subprice = $pu_ht; + $line->total_ht = $total_ht; + $line->total_tva = $total_tva; + $line->total_localtax1 = $total_localtax1; + $line->total_localtax2 = $total_localtax2; + $line->total_ttc = $total_ttc; + $line->info_bits = $info_bits; + $line->price_ht = $price; + $line->remise = $remise; - $resql=$this->db->query($sql); - if ($resql) - { - $result=$this->update_statut($user); - if ($result > 0) - { - // Call trigger - $result=$this->call_trigger('LINECONTRACT_CREATE',$user); - if ($result < 0) - { - $this->db->rollback(); - return -1; - } - // End call triggers - - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } + if (isset($fk_fournprice)) { + $line->fk_fournprice = $fk_fournprice; } - else - { + + if (isset($pa_ht)) { + $line->pa_ht = $pa_ht; + } + $line->date_ouverture_prevue = $date_start; + $line->date_fin_validite = $date_end; + + $result = $line->insert(); + + if ($result < 1) { $this->db->rollback(); - $this->error=$this->db->error()." sql=".$sql; return -1; } + + $this->db->commit(); + return 1; } else { @@ -2545,4 +2526,71 @@ class ContratLigne extends CommonObject } } + + /** + * Inserts a contrat line into database + * + * @param int $notrigger Set to 1 if you don't want triggers to be fired + * @return int <0 if KO, >0 if OK + */ + public function insert($notrigger = 0) + { + global $user; + + // Insertion dans la base + $sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet"; + $sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,"; + $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,"; + $sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,"; + $sql.= " info_bits,"; + $sql.= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht"; + if ($this->date_ouverture_prevue > 0) { $sql.= ",date_ouverture_prevue"; } + if ($this->date_fin_validite > 0) { $sql.= ",date_fin_validite"; } + $sql.= ") VALUES ($this->fk_contrat, '', '" . $this->db->escape($this->description) . "',"; + $sql.= ($this->fk_product>0 ? $this->fk_product : "null").","; + $sql.= " '".$this->qty."',"; + $sql.= " '".$this->tva_tx."',"; + $sql.= " '".$this->localtax1_tx."',"; + $sql.= " '".$this->localtax2_tx."',"; + $sql.= " '".$this->localtax1_type."',"; + $sql.= " '".$this->localtax2_type."',"; + $sql.= " ".price2num($this->remise_percent).",".price2num($this->subprice).","; + $sql.= " ".price2num($this->total_ht).",".price2num($this->total_tva).",".price2num($this->total_localtax1).",".price2num($this->total_localtax2).",".price2num($this->total_ttc).","; + $sql.= " '".$this->info_bits."',"; + $sql.= " ".price2num($this->price_ht).",".price2num($this->remise).","; + if ($this->fk_fournprice > 0) $sql.= ' '.$this->fk_fournprice.','; + else $sql.= ' null,'; + if ($this->pa_ht > 0) $sql.= ' '.price2num($this->pa_ht); + else $sql.= ' null'; + if ($this->date_ouverture_prevue > 0) { $sql.= ",'".$this->db->idate($this->date_ouverture_prevue)."'"; } + if ($this->date_fin_validite > 0) { $sql.= ",'".$this->db->idate($this->date_fin_validite)."'"; } + $sql.= ")"; + + dol_syslog(get_class($this)."::insert", LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'contratdet'); + + if (!$notrigger) { + // Call trigger + $result = $this->call_trigger('LINECONTRACT_CREATE', $user); + if ($result < 0) { + $this->db->rollback(); + return -1; + } + // End call triggers + } + + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + $this->error=$this->db->error()." sql=".$sql; + return -1; + } + } } From 9e35fd1bc3779ffaec9b09344956cf0ea8e7008c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Jul 2015 11:04:01 +0200 Subject: [PATCH 2/9] Doc comments --- htdocs/comm/action/class/actioncomm.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c868cb8569c..341924ffa13 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -106,8 +106,8 @@ class ActionComm extends CommonObject var $note; // Description var $userassigned = array(); // Array of user ids - var $userownerid; // Id of user owner - var $userdoneid; // Id of user done + var $userownerid; // Id of user owner = fk_user_action into table + var $userdoneid; // Id of user done (deprecated) /** * Object user of owner From fa26b284a9ddfc978ef65187f9e1643a4eba7806 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Tue, 21 Jul 2015 16:39:00 +0200 Subject: [PATCH 3/9] FIX : Line break display as a block --- htdocs/core/class/extrafields.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5545dc7cd5d..5897427fe27 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1035,6 +1035,10 @@ class ExtraFields } } } + if ($type == 'text') + { + $value=nl2br($value); + } else { $showsize=round($size); From c0412acdea3ee24faf0a8cb0909508c49eb685fc Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 27 Jul 2015 13:03:47 +0200 Subject: [PATCH 4/9] FIX : #3318 --- htdocs/adherents/admin/public.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/admin/public.php b/htdocs/adherents/admin/public.php index 740a5c97879..088f96b00c1 100644 --- a/htdocs/adherents/admin/public.php +++ b/htdocs/adherents/admin/public.php @@ -215,7 +215,12 @@ dol_fiche_end(); print '
'; //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('','object_globe.png').' '.$langs->trans('BlankSubscriptionForm').':
'; -print ''.DOL_MAIN_URL_ROOT.'/public/members/new.php'; +if ($conf->multicompany->enabled) { + $entity_qr='?entity='.$conf->entity; +} else { + $entity_qr=''; +} +print ''.DOL_MAIN_URL_ROOT.'/public/members/new.php'.$entity_qr.''; /* print ''; From e130af80336025a5fe20278ecbb18156e9c37287 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Mon, 27 Jul 2015 13:11:07 +0200 Subject: [PATCH 5/9] Fix: Not showing delivery date on rouget pdf (expedition) --- ChangeLog | 1 + htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 56e04ded436..7016359ae74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ FIX [ bug #3055 ] Product image thumbnails were not deleted after deleting the i FIX [ bug 1634 ] Error deleting a project when it had many linked objects FIX [ bug 1925 ] "Link to order" option in supplier invoices is not working properly FIX [ bug #3198 ] Trigger LINECONTRACT_INSERT passes Contrat as $object instead of ContratLigne +FIX: Not showing delivery date on rouget pdf NEW: Created new ContratLigne::insert function diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 9c5dada3a72..847cf98aa36 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -544,7 +544,7 @@ class pdf_rouget extends ModelePdfExpedition $posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true), '', 'R'); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"daytext",false,$outputlangs,true), '', 'R'); if (! empty($object->client->code_client)) { From d78292b9af3b5e477ae4587fc9cc08dd79896055 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 27 Jul 2015 22:08:33 +0200 Subject: [PATCH 6/9] FIX : if multicompany enabled, call to undifend method _setCookie instead of setCookie --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8fbd48bc855..cd8377ca5a8 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -660,7 +660,7 @@ if (! defined('NOLOGIN')) $cryptkey = (! empty($conf->file->cookie_cryptkey) ? $conf->file->cookie_cryptkey : '' ); $entityCookie = new DolCookie($cryptkey); - $entityCookie->_setCookie($entityCookieName, $entity, $ttl); + $entityCookie->setCookie($entityCookieName, $entity, $ttl); } // Hooks on successfull login From 517e9094da6fcee5c3594140f2f965550b7d282e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 27 Jul 2015 22:34:30 +0200 Subject: [PATCH 7/9] FIX : Avoid warning strict mode when hosting server do not have php5_curl installed --- htdocs/core/lib/json.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index ba7f4cd3f90..ca79c21e9ef 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -251,7 +251,9 @@ function dol_json_decode($json, $assoc=false) if (! empty($array)) { $object = false; - + if (count($array)>0) { + $object = (object) array(); + } foreach ($array as $key => $value) { if ($key) $object->{$key} = $value; From 556d01ff8abdfd91794d2da7d708ef02b61b24a9 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Tue, 28 Jul 2015 15:14:54 +0200 Subject: [PATCH 8/9] FIX : Line break display as a block --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5897427fe27..99ec23c6a73 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1037,7 +1037,7 @@ class ExtraFields } if ($type == 'text') { - $value=nl2br($value); + $value=dol_htmlentitiesbr($value); } else { From aaa9d85d079651f848a00a8fdb4af459036359d6 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Tue, 28 Jul 2015 17:25:33 +0200 Subject: [PATCH 9/9] FIX : When we add an user on event in create mode, we lose linked object --- htdocs/comm/action/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 8dce1b39df0..2e35b8004f0 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -751,6 +751,8 @@ if ($action == 'create') print ''; print ''; print ''; + print ''; + print ''; } if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',GETPOST("datep"),$reg))
'.dolGetElementUrl($originid,$origin,1).'