Merge pull request #1937 from fappels/develop

Expedition lines from same orderline merged.
This commit is contained in:
Laurent Destailleur 2014-10-04 00:58:19 +02:00
commit e70aebf2c7
5 changed files with 67 additions and 14 deletions

View File

@ -100,8 +100,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->posxcomm=112; $this->posxcomm=112;
//$this->posxtva=112; //$this->posxtva=112;
//$this->posxup=126; //$this->posxup=126;
$this->posxqty=174; $this->posxqty=165;
$this->posxremainingqty=165; $this->posxremainingqty=185;
//$this->posxdiscount=162; //$this->posxdiscount=162;
//$this->postotalht=174; //$this->postotalht=174;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format

View File

@ -7,6 +7,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr> * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Francis Appels <francis.appels@yahoo.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1433,6 +1434,18 @@ else if ($id || $ref)
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
$entrepot->fetch($lines[$i]->entrepot_id); $entrepot->fetch($lines[$i]->entrepot_id);
print $entrepot->getNomUrl(1); print $entrepot->getNomUrl(1);
}
else if (count($lines[$i]->details_entrepot) > 1)
{
$detail = '';
foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
if ($detail_entrepot->entrepot_id > 0) {
$entrepot = new Entrepot($db);
$entrepot->fetch($detail_entrepot->entrepot_id);
$detail.= $langs->trans("DetailWarehouseFormat",$entrepot->libelle,$detail_entrepot->qty_shipped).'<br/>';
}
}
print $form->textwithtooltip($langs->trans("DetailWarehouseNumber"),$detail);
} }
print '</td>'; print '</td>';
} }
@ -1440,6 +1453,7 @@ else if ($id || $ref)
// Batch number managment // Batch number managment
if (! empty($conf->productbatch->enabled)) { if (! empty($conf->productbatch->enabled)) {
if (isset($lines[$i]->detail_batch) ) { if (isset($lines[$i]->detail_batch) ) {
$flagBatch = true;
print '<td align="center">'; print '<td align="center">';
$detail = ''; $detail = '';
foreach ($lines[$i]->detail_batch as $dbatch) { foreach ($lines[$i]->detail_batch as $dbatch) {
@ -1526,10 +1540,17 @@ else if ($id || $ref)
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans($label).'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans($label).'</a>';
} }
} }
if ($user->rights->expedition->supprimer) if ($user->rights->expedition->supprimer)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>'; if (empty($conf->productbatch->enabled) || (!empty($conf->productbatch->enabled) && !$conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !isset($flagBatch))
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
else
{
print '<a class="butActionRefused" href="#">'.$langs->trans('Delete').'</a>';
}
} }
print '</div>'; print '</div>';

View File

@ -7,6 +7,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr> * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Francis Appels <francis.appels@yahoo.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1068,7 +1069,7 @@ class Expedition extends CommonObject
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
$sql.= " WHERE ed.fk_expedition = ".$this->id; $sql.= " WHERE ed.fk_expedition = ".$this->id;
$sql.= " AND ed.fk_origin_line = cd.rowid"; $sql.= " AND ed.fk_origin_line = cd.rowid";
$sql.= " ORDER BY cd.rang"; $sql.= " ORDER BY cd.rang, ed.fk_origin_line";
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1078,6 +1079,8 @@ class Expedition extends CommonObject
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
$lineindex = 0;
$originline = 0;
$this->total_ht = 0; $this->total_ht = 0;
$this->total_tva = 0; $this->total_tva = 0;
@ -1087,13 +1090,25 @@ class Expedition extends CommonObject
while ($i < $num) while ($i < $num)
{ {
$line = new ExpeditionLigne($this->db); $obj = $this->db->fetch_object($resql);
$obj = $this->db->fetch_object($resql);
if ($originline == $obj->fk_origin_line) {
$line->entrepot_id = 0; // entrepod_id in details_entrepot
$line->qty_shipped += $obj->qty_shipped;
} else {
$line = new ExpeditionLigne($this->db);
$line->entrepot_id = $obj->fk_entrepot;
$line->qty_shipped = $obj->qty_shipped;
}
$detail_entrepot = new stdClass;
$detail_entrepot->entrepot_id = $obj->fk_entrepot;
$detail_entrepot->qty_shipped = $obj->qty_shipped;
$line->details_entrepot[] = $detail_entrepot;
$line->line_id = $obj->line_id; $line->line_id = $obj->line_id;
$line->fk_origin_line = $obj->fk_origin_line; $line->fk_origin_line = $obj->fk_origin_line;
$line->origin_line_id = $obj->fk_origin_line; // TODO deprecated $line->origin_line_id = $obj->fk_origin_line; // TODO deprecated
$line->entrepot_id = $obj->fk_entrepot;
$line->fk_product = $obj->fk_product; $line->fk_product = $obj->fk_product;
$line->fk_product_type = $obj->fk_product_type; $line->fk_product_type = $obj->fk_product_type;
$line->ref = $obj->product_ref; // TODO deprecated $line->ref = $obj->product_ref; // TODO deprecated
@ -1103,7 +1118,6 @@ class Expedition extends CommonObject
$line->label = $obj->custom_label; $line->label = $obj->custom_label;
$line->description = $obj->description; $line->description = $obj->description;
$line->qty_asked = $obj->qty_asked; $line->qty_asked = $obj->qty_asked;
$line->qty_shipped = $obj->qty_shipped;
$line->weight = $obj->weight; $line->weight = $obj->weight;
$line->weight_units = $obj->weight_units; $line->weight_units = $obj->weight_units;
$line->length = $obj->length; $line->length = $obj->length;
@ -1116,7 +1130,7 @@ class Expedition extends CommonObject
// For invoicing // For invoicing
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type); // We force type to 0 $tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->fk_product_type); // We force type to 0
$line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements) $line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements)
$line->qty = $obj->qty_shipped; $line->qty = $line->qty_shipped;
$line->total_ht = $tabprice[0]; $line->total_ht = $tabprice[0];
$line->total_localtax1 = $tabprice[9]; $line->total_localtax1 = $tabprice[9];
$line->total_localtax2 = $tabprice[10]; $line->total_localtax2 = $tabprice[10];
@ -1141,11 +1155,25 @@ class Expedition extends CommonObject
* May be conf is not well initialized for dark reason * May be conf is not well initialized for dark reason
*/ */
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
$line->detail_batch=ExpeditionLigneBatch::FetchAll($this->db,$obj->line_id); if ($originline != $obj->fk_origin_line) {
$line->detail_batch = ExpeditionLigneBatch::FetchAll($this->db,$obj->line_id);
} else {
$line->detail_batch = array_merge($line->detail_batch,ExpeditionLigneBatch::FetchAll($this->db,$obj->line_id));
}
}
if ($originline != $obj->fk_origin_line) {
$this->lines[$lineindex] = $line;
$lineindex++;
} else {
$line->total_ht += $tabprice[0];
$line->total_localtax1 += $tabprice[9];
$line->total_localtax2 += $tabprice[10];
$line->total_ttc += $tabprice[2];
$line->total_tva += $tabprice[1];
} }
$this->lines[$i] = $line;
$i++; $i++;
$originline = $obj->fk_origin_line;
} }
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;

View File

@ -74,7 +74,7 @@ ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL
ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT NULL AFTER account_number; ALTER TABLE llx_bank_account ADD COLUMN accountancy_journal varchar(3) DEFAULT NULL AFTER account_number;
ALTER TABLE llx_accountingaccount add column entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_accountingaccount add column entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_accountingaccount add column datec datetime NOT NULL AFTER entity; ALTER TABLE llx_accountingaccount add column datec datetime AFTER entity;
ALTER TABLE llx_accountingaccount add column tms timestamp AFTER datec; ALTER TABLE llx_accountingaccount add column tms timestamp AFTER datec;
ALTER TABLE llx_accountingaccount add column fk_user_author integer DEFAULT NULL AFTER label; ALTER TABLE llx_accountingaccount add column fk_user_author integer DEFAULT NULL AFTER label;
ALTER TABLE llx_accountingaccount add column fk_user_modif integer DEFAULT NULL AFTER fk_user_author; ALTER TABLE llx_accountingaccount add column fk_user_modif integer DEFAULT NULL AFTER fk_user_author;

View File

@ -72,3 +72,7 @@ DocumentModelTyphon=More complete document model for delivery receipts (logo...)
Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constant EXPEDITION_ADDON_NUMBER not defined Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constant EXPEDITION_ADDON_NUMBER not defined
SumOfProductVolumes=Sum of product volumes SumOfProductVolumes=Sum of product volumes
SumOfProductWeights=Sum of product weights SumOfProductWeights=Sum of product weights
# warehouse details
DetailWarehouseNumber= Warehouse details
DetailWarehouseFormat= W:%s (Qty : %d)