Works on Milestone module

This commit is contained in:
Regis Houssin 2010-07-02 15:38:32 +00:00
parent 0c3d8b58f1
commit f430b54cca
6 changed files with 40 additions and 26 deletions

View File

@ -141,6 +141,8 @@ if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes'
$propal->fetch($_GET["id"]); $propal->fetch($_GET["id"]);
$propal->fetch_client(); $propal->fetch_client();
$result = $propal->delete_product($_GET['lineid']); $result = $propal->delete_product($_GET['lineid']);
// reorder lines
if ($result) $propal->line_order(true);
// Define output language // Define output language
$outputlangs = $langs; $outputlangs = $langs;
@ -1409,31 +1411,29 @@ if ($id > 0 || ! empty($ref))
$lines = $propal->getLinesArray(); $lines = $propal->getLinesArray();
// Show lines // Milestone module
if (! empty($lines) ) if ($conf->milestone->enabled)
{ {
print_title_list(); $milestone = new Milestone($db);
$milestone->getObjectMilestones($propal);
// Milestone module $sublines = $propal->getLinesArray(false);
if ($conf->milestone->enabled)
{
$milestone = new Milestone($db);
$milestone->getObjectMilestones($propal);
if (! empty($milestone->lines)) if (! empty($milestone->lines))
{
print_milestone_list($milestone, $propal, $lines);
}
else
{
print_lines_list($propal, $lines);
}
}
else
{ {
print_title_list();
print_milestone_list($milestone, $sublines, $propal, $lines);
}
else if (! empty($lines) )
{
print_title_list();
print_lines_list($propal, $lines); print_lines_list($propal, $lines);
} }
} }
else if (! empty($lines) )
{
print_title_list();
print_lines_list($propal, $lines);
}
/* /*
* Form to add new line * Form to add new line

View File

@ -2151,21 +2151,21 @@ class Propal extends CommonObject
/** /**
* \brief Return an array of propal lines * \brief Return an array of propal lines
*/ */
function getLinesArray() function getLinesArray($order=true)
{ {
$lines = array(); $lines = array();
$sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,'; $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.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.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_start, pt.date_end, pt.product_type, pt.rang,';
$sql.= ' pt.date_end,';
$sql.= ' pt.product_type,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
$sql.= ' p.description as product_desc'; $sql.= ' p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
$sql.= ' WHERE pt.fk_propal = '.$this->id; $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'; $sql.= ' ORDER BY pt.rang ASC, pt.rowid';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -2199,6 +2199,7 @@ class Propal extends CommonObject
$lines[$i]->marge_tx = $obj->marge_tx; $lines[$i]->marge_tx = $obj->marge_tx;
$lines[$i]->marque_tx = $obj->marque_tx; $lines[$i]->marque_tx = $obj->marque_tx;
$lines[$i]->special_code = $obj->special_code; $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_start = $this->db->jdate($obj->date_start);
$lines[$i]->date_end = $this->db->jdate($obj->date_end); $lines[$i]->date_end = $this->db->jdate($obj->date_end);

View File

@ -698,6 +698,7 @@ class CommonObject
$sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql.= ' WHERE '.$this->fk_element.'='.$this->id; $sql.= ' WHERE '.$this->fk_element.'='.$this->id;
if (! $renum) $sql.= ' AND rang = 0'; if (! $renum) $sql.= ' AND rang = 0';
if ($renum) $sql.= ' AND rang <> 0';
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -3459,4 +3459,17 @@ function picto_from_langcode($codelang)
return $ret; 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;
}
?> ?>

View File

@ -162,7 +162,7 @@ function print_line($propal,$line,$var=true,$num=0,$i=0)
global $db; global $db;
global $conf,$langs,$user; global $conf,$langs,$user;
global $html,$bc; global $html,$bc;
// Show product and description // Show product and description
$type=$line->product_type?$line->product_type:$line->fk_product_type; $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 // Try to enhance type detection using date_start and date_end for free lines where type

View File

@ -675,8 +675,7 @@ if (! defined('NOREQUIRETRAN'))
} }
// Define some constants used for style of arrays // Define some constants used for style of arrays
$bc[0]="class=\"impair\""; $bc = bcStyle();
$bc[1]="class=\"pair\"";
// Constants used to defined number of lines in textarea // Constants used to defined number of lines in textarea
if (empty($conf->browser->firefox)) if (empty($conf->browser->firefox))