From 914e4a4bf18c2661e093060f15ff61830ba07008 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 7 Apr 2011 10:18:41 +0000 Subject: [PATCH] Fix: product lines with parent line better works Fix: add trigger LINEPROPAL_DELETE --- htdocs/comm/propal/class/propal.class.php | 31 +++++++++++++++--- htdocs/core/class/html.form.class.php | 8 +++-- htdocs/core/tpl/freeproductline_view.tpl.php | 1 + .../tpl/predefinedproductline_view.tpl.php | 6 ++-- .../interface_all_Demo.class.php-NORUN | 4 +++ htdocs/theme/auguria/img/rightarrow.png | Bin 0 -> 507 bytes 6 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 htdocs/theme/auguria/img/rightarrow.png diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d7591bc7beb..322be49d1a6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -542,9 +542,9 @@ class Propal extends CommonObject { if ($this->statut == 0) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$lineid; + $line=new PropaleLigne($this->db); - if ($this->db->query($sql) ) + if ($line->delete($lineid)) { $this->update_price(); @@ -2453,8 +2453,31 @@ class PropaleLigne return -1; } } - - + + /** + * Delete line in database + * @return int <0 si ko, >0 si ok + */ + function delete($rowid) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$rowid; + if ($this->db->query($sql) ) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result = $interface->run_triggers('LINEPROPAL_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // Fin appel triggers + + return 1; + } + else + { + return -1; + } + } + /** * \brief Mise a jour de l'objet ligne de propale en base * \return int <0 si ko, >0 si ok diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3b55841a03d..fc5be47322b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -146,14 +146,16 @@ class Form * @param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres * @param img Code img du picto (use img_xxx() function to get it) * @param extracss Add a CSS style to td tags - * @param notable Do not include table and tr tags + * @param notabs Do not include table and tr tags + * @param incbefore Include code before the text * @return string Code html du tooltip (texte+picto) * @see Use function textwithpicto if you can. */ - function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0) + function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='') { global $conf; - + + if ($incbefore) $text = $incbefore.$text; if (! $htmltext) return $text; $paramfortooltip =''; diff --git a/htdocs/core/tpl/freeproductline_view.tpl.php b/htdocs/core/tpl/freeproductline_view.tpl.php index d561f46b101..15defba59d8 100644 --- a/htdocs/core/tpl/freeproductline_view.tpl.php +++ b/htdocs/core/tpl/freeproductline_view.tpl.php @@ -41,6 +41,7 @@ } } } else { + if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); if ($type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); echo $text.' '.nl2br($line->description); diff --git a/htdocs/core/tpl/predefinedproductline_view.tpl.php b/htdocs/core/tpl/predefinedproductline_view.tpl.php index 6dce97bacec..7f327864a0a 100644 --- a/htdocs/core/tpl/predefinedproductline_view.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_view.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010 Laurent Destailleur +/* Copyright (C) 2010-2011 Regis Houssin + * Copyright (C) 2010-2011 Laurent Destailleur * * 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 @@ -25,7 +25,7 @@ textwithtooltip($text,$description,3,'','',$i); + echo $html->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); // Show range print_date_range($line->date_start, $line->date_end); diff --git a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN index 464dd232223..662c7400875 100644 --- a/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN +++ b/htdocs/includes/triggers/interface_all_Demo.class.php-NORUN @@ -281,6 +281,10 @@ class InterfaceDemo { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } + elseif ($action == 'LINEPROPAL_MODIFY') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } elseif ($action == 'LINEPROPAL_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); diff --git a/htdocs/theme/auguria/img/rightarrow.png b/htdocs/theme/auguria/img/rightarrow.png new file mode 100644 index 0000000000000000000000000000000000000000..eb0310ee0cba81eb4cd917c0360e2c197582b320 GIT binary patch literal 507 zcmVJNRCwB?l21$HP!z>~FG>Gst=7MT zsN;wXC@8L62rhJ`D_zQnAoxlA2=2sBFzW$v1Q!akm~p3IrJx%ts7)=jO9mAbgXpl17TUxvWhD1lqAo@d92<)Y<{c=)!ec*k?=Ex~fm8iTzqY7;M=3k}Z=@ z#z|fMB%L^uV8P(Oq2B19wP?GJhf~UnjVY>y6t$PE{4A@st?P{0bdPN@v9wIB3YC13 z%*_Sn^&utmx8z;Y5rgN%dpqr6bRHrDdwiMOz>NPQb9*F{{1yAtbPdbthaebv7c$zu x-qwST^?1&ch!~+$iW#}`Lk$7-x&K!I1_0rpzLpUWQ>Op`002ovPDHLkV1h{C>Fodj literal 0 HcmV?d00001