From f430b54cca0261f45858eda919799c559afa0a08 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 2 Jul 2010 15:38:32 +0000 Subject: [PATCH] Works on Milestone module --- htdocs/comm/propal.php | 38 +++++++++++------------ htdocs/comm/propal/class/propal.class.php | 9 +++--- htdocs/core/class/commonobject.class.php | 1 + htdocs/lib/functions.lib.php | 13 ++++++++ htdocs/lib/propal.lib.php | 2 +- htdocs/main.inc.php | 3 +- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index da75769bea1..0cac7664b6a 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -141,6 +141,8 @@ if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes' $propal->fetch($_GET["id"]); $propal->fetch_client(); $result = $propal->delete_product($_GET['lineid']); + // reorder lines + if ($result) $propal->line_order(true); // Define output language $outputlangs = $langs; @@ -1409,31 +1411,29 @@ if ($id > 0 || ! empty($ref)) $lines = $propal->getLinesArray(); - // Show lines - if (! empty($lines) ) + // Milestone module + if ($conf->milestone->enabled) { - print_title_list(); - - // Milestone module - if ($conf->milestone->enabled) - { - $milestone = new Milestone($db); - $milestone->getObjectMilestones($propal); + $milestone = new Milestone($db); + $milestone->getObjectMilestones($propal); + $sublines = $propal->getLinesArray(false); - if (! empty($milestone->lines)) - { - print_milestone_list($milestone, $propal, $lines); - } - else - { - print_lines_list($propal, $lines); - } - } - else + if (! empty($milestone->lines)) { + print_title_list(); + print_milestone_list($milestone, $sublines, $propal, $lines); + } + else if (! empty($lines) ) + { + print_title_list(); print_lines_list($propal, $lines); } } + else if (! empty($lines) ) + { + print_title_list(); + print_lines_list($propal, $lines); + } /* * Form to add new line diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6138f1c11e5..a9227385c86 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2151,21 +2151,21 @@ class Propal extends CommonObject /** * \brief Return an array of propal lines */ - function getLinesArray() + function getLinesArray($order=true) { $lines = array(); $sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.marge_tx, pt.marque_tx, pt.pa_ht, pt.special_code,'; - $sql.= ' pt.date_start,'; - $sql.= ' pt.date_end,'; - $sql.= ' pt.product_type,'; + $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_propal = '.$this->id; + if ($order) $sql.= ' AND pt.rang <> 0'; + if (! $order) $sql.= ' AND pt.rang = 0'; $sql.= ' ORDER BY pt.rang ASC, pt.rowid'; $resql = $this->db->query($sql); @@ -2199,6 +2199,7 @@ class Propal extends CommonObject $lines[$i]->marge_tx = $obj->marge_tx; $lines[$i]->marque_tx = $obj->marque_tx; $lines[$i]->special_code = $obj->special_code; + $lines[$i]->rang = $obj->rang; $lines[$i]->date_start = $this->db->jdate($obj->date_start); $lines[$i]->date_end = $this->db->jdate($obj->date_end); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ac148ea0ca2..890f6a20638 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -698,6 +698,7 @@ class CommonObject $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.'='.$this->id; if (! $renum) $sql.= ' AND rang = 0'; + if ($renum) $sql.= ' AND rang <> 0'; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 771f471dae2..aa049e7e2dc 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -3459,4 +3459,17 @@ function picto_from_langcode($codelang) return $ret; } +/** + * \brief Define the style of background color of line + */ +function bcStyle($impair='impair', $pair='pair') +{ + $bc=array(); + + $bc[0]='class="'.$impair.'"'; + $bc[1]='class="'.$pair.'"'; + + return $bc; +} + ?> \ No newline at end of file diff --git a/htdocs/lib/propal.lib.php b/htdocs/lib/propal.lib.php index 69366f8d67b..c85d7a6307c 100644 --- a/htdocs/lib/propal.lib.php +++ b/htdocs/lib/propal.lib.php @@ -162,7 +162,7 @@ function print_line($propal,$line,$var=true,$num=0,$i=0) global $db; global $conf,$langs,$user; global $html,$bc; - + // Show product and description $type=$line->product_type?$line->product_type:$line->fk_product_type; // Try to enhance type detection using date_start and date_end for free lines where type diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 936f25211e0..27ccb56dd50 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -675,8 +675,7 @@ if (! defined('NOREQUIRETRAN')) } // Define some constants used for style of arrays -$bc[0]="class=\"impair\""; -$bc[1]="class=\"pair\""; +$bc = bcStyle(); // Constants used to defined number of lines in textarea if (empty($conf->browser->firefox))