Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2016-06-12 20:24:23 +02:00
commit 0602986588
8 changed files with 73 additions and 261 deletions

View File

@ -1863,9 +1863,9 @@ class Commande extends CommonOrder
/**
* Load array this->expeditions of lines of shipments with nb of products sent for each order line
* Note: For a dedicated shipment, the fetch_lines load the qty_asked and qty_shipped. This function return qty_shipped cuulated for order
* Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
*
* @param int $filtre_statut Filter on status
* @param int $filtre_statut Filter on shipment status
* @return int <0 if KO, Nb of lines found if OK
*/
function loadExpeditions($filtre_statut=-1)
@ -1934,21 +1934,6 @@ class Commande extends CommonOrder
else dol_print_error($this->db);
}
/**
* Return a array with sendings by line
*
* @param int $filtre_statut Filtre sur statut
* @return int 0 si OK, <0 si KO
*
* TODO deprecate, move to Shipping class
*/
function livraison_array($filtre_statut=self::STATUS_CANCELED)
{
$delivery = new Livraison($this->db);
$deliveryArray = $delivery->livraison_array($filtre_statut);
return $deliveryArray;
}
/**
* Return a array with the pending stock by product
*

View File

@ -69,7 +69,7 @@ else
$typeid=$_REQUEST['typeid'];
}
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$search_ref="";
$search_label="";
@ -211,6 +211,8 @@ if ($resql)
print '</td>';
print "</tr>\n";
$i=0;
$totalarray=array();
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($resql);
@ -244,8 +246,12 @@ if ($resql)
}
print '</td>';
// Amount
print '<td align="right" width="100">'.price($obj->amount).'</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
$totalarray['totalttc'] += $obj->amount;
// Due date
print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
@ -257,6 +263,22 @@ if ($resql)
$i++;
}
// Show total line
if (isset($totalarray['totalttcfield']))
{
print '<tr class="liste_total">';
if ($num < $limit) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td align="right">'.price($totalarray['totalttc']).'</td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '</tr>';
}
print '</table>';
}
print '</form>';

View File

@ -93,6 +93,13 @@ class Expedition extends CommonObject
var $meths;
var $listmeths; // List of carriers
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
const STATUS_CLOSED = 2;
/**
* Constructor
*
@ -1794,9 +1801,9 @@ class Expedition extends CommonObject
}
/**
* Classify the shipping as closed
* Classify the shipping as closed.
*
* @return int <0 if ko, >0 if ok
* @return int <0 if KO, >0 if OK
*/
function setClosed()
{
@ -1806,15 +1813,43 @@ class Expedition extends CommonObject
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=2';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut='.self::STATUS_CLOSED;
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0';
$resql=$this->db->query($sql);
if ($resql)
{
// TODO: Add option/checkbox to set order billed if 100% of order is shipped
$this->statut=2;
// Set order billed if 100% of order is shipped (qty in shipment lines match qty in order lines)
if ($this->origin == 'commande' && $this->origin_id > 0)
{
$order = new Commande($this->db);
$order->fetch($this->origin_id);
$order->loadExpeditions(self::STATUS_CLOSED); // Fill $order->expeditions = array(orderlineid => qty)
$shipments_match_order = 1;
foreach($order->lines as $line)
{
$lineid = $line->id;
$qty = $line->qty;
if (($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && $order->expeditions[$lineid] != $qty)
{
$shipments_match_order = 0;
$text='Qty for order line id '.$lineid.' is '.$qty.' but in shipments with status Expedition::STATUS_CLOSED='.self::STATUS_CLOSED.', we have '.$order->expeditions[$lineid].' so we can t close order';
dol_syslog($text);
break;
}
}
if ($shipments_match_order)
{
dol_syslog("Qty for the ".count($order->lines)." lines of order have same value for shipments with status Expedition::STATUS_CLOSED=".self::STATUS_CLOSED.', so we close order');
$order->cloture($user);
}
}
$this->statut=self::STATUS_CLOSED;
// If stock increment is done on closing
if (! $error && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE))
{
@ -1823,7 +1858,7 @@ class Expedition extends CommonObject
$langs->load("agenda");
// Loop on each product line to add a stock movement
// TODO possibilite d'expedier a partir d'une propale ou autre origine
// TODO possibilite d'expedier a partir d'une propale ou autre origine ?
$sql = "SELECT cd.fk_product, cd.subprice,";
$sql.= " ed.rowid, ed.qty, ed.fk_entrepot,";
$sql.= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock";

View File

@ -1,27 +0,0 @@
-- ============================================================================
-- Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
--
-- 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
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ============================================================================
create table llx_element_lock
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_element integer NOT NULL,
elementtype varchar(32) NOT NULL,
datel datetime, -- date of lock
datem datetime, -- date of unlock/modif
sessionid varchar(255)
)ENGINE=innodb;

View File

@ -72,6 +72,7 @@ ProductQtyInSuppliersShipmentAlreadyRecevied=Product quantity from opened suppli
NoProductToShipFoundIntoStock=No product to ship found into warehouse <b>%s</b>. Correct stock or go back to choose another warehouse.
WeightVolShort=Weight/Vol.
ValidateOrderFirstBeforeShipment=You must first validate the order before being able to make shipments.
CloseShippeOrdersAutomatically=Classify the order "Delivered" if entirely shipped.
# Sending methods
SendingMethodCATCH=Catch by customer

View File

@ -300,213 +300,7 @@ $formfile = new FormFile($db);
if ($action == 'create') // Seems to no be used
{
print load_fiche_titre($langs->trans("CreateADeliveryOrder"));
if ($mesg)
{
print $mesg.'<br>';
}
$commande = new Commande($db);
$commande->livraison_array();
if ($commande->fetch(GETPOST("commande_id")))
{
$soc = new Societe($db);
$soc->fetch($commande->socid);
$author = new User($db);
$author->fetch($commande->user_author_id);
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
{
$entrepot = new Entrepot($db);
}
/*
* Commande
*/
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
{
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
}
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
print '<td width="30%"><b><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$soc->id.'">'.$soc->name.'</a></b></td>';
print '<td width="50%" colspan="2">';
print "</td></tr>";
print "<tr><td>".$langs->trans("Date")."</td>";
print "<td>".dol_print_date($commande->date,'dayhourtext')."</td>\n";
print '<td>'.$langs->trans("Order").'</td><td><a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$commande->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'</a>';
print "</td></tr>\n";
print '<tr>';
if (!$conf->expedition_bon->enabled && ! empty($conf->stock->enabled))
{
print '<td>'.$langs->trans("Warehouse").'</td>';
print '<td>';
$ents = $entrepot->list_array();
print '<a href="'.DOL_URL_ROOT.'/product/stock/card.php?id='.$_GET["entrepot_id"].'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$ents[$_GET["entrepot_id"]].'</a>';
print '</td>';
}
print "<td>".$langs->trans("Author")."</td><td>".$author->getFullName($langs)."</td>\n";
if ($commande->note)
{
print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>";
}
print "</table>";
/*
* Lignes de commandes
*/
print '<br><table class="noborder" width="100%">';
$commande->fetch_lines(1);
$lines = $commande->lines;
// Lecture des livraisons deja effectuees
$commande->livraison_array();
$num = count($commande->lines);
$i = 0;
if ($num)
{
print '<tr class="liste_titre">';
print '<td width="54%">'.$langs->trans("Description").'</td>';
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
print '<td align="center">'.$langs->trans("QtyToShip").'</td>';
if (! empty($conf->stock->enabled))
{
print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>';
}
print "</tr>\n";
}
$var=true;
while ($i < $num)
{
$product = new Product($db);
$line = $commande->lines[$i];
$var=!$var;
print "<tr ".$bc[$var].">\n";
if ($line->fk_product > 0)
{
$product->fetch($line->fk_product);
$product->load_stock();
// Define output language
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
$commande->fetch_thirdparty();
$outputlangs = $langs;
$newlang='';
if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
if (empty($newlang)) $newlang=$commande->thirdparty->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
$label = (! empty($product->multilangs[$outputlangs->defaultlang]["label"])) ? $product->multilangs[$outputlangs->defaultlang]["label"] : $product->label;
}
else
$label = (! empty($line->label)?$line->label:$product->label);
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$line->fk_product.'">'.img_object($langs->trans("ShowProduct"),"product").' '.$product->ref.'</a> - '.$label;
if ($line->description) print nl2br($line->description);
print '</td>';
}
else
{
print "<td>";
if ($line->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
else $text = img_object($langs->trans('Product'),'product');
if (! empty($line->label)) {
$text.= ' <strong>'.$line->label.'</strong>';
print $form->textwithtooltip($text,$line->description,3,'','',$i);
} else {
print $text.' '.nl2br($line->description);
}
print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
print "</td>\n";
}
print '<td align="center">'.$line->qty.'</td>';
/*
*
*/
print '<td align="center">';
$quantite_livree = $commande->livraisons[$line->id];
print $quantite_livree;
print '</td>';
$quantite_commandee = $line->qty;
$quantite_a_livrer = $quantite_commandee - $quantite_livree;
if (! empty($conf->stock->enabled))
{
$stock = $product->stock_warehouse[$_GET["entrepot_id"]]->real;
$stock+=0; // Convertit en numerique
// Quantite a livrer
print '<td align="center">';
print '<input name="idl'.$i.'" type="hidden" value="'.$line->id.'">';
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.min($quantite_a_livrer, $stock).'">';
print '</td>';
// Stock
if ($stock < $quantite_a_livrer)
{
print '<td align="center">'.$stock.' '.img_warning().'</td>';
}
else
{
print '<td align="center">'.$stock.'</td>';
}
}
else
{
// Quantite a livrer
print '<td align="center">';
print '<input name="idl'.$i.'" type="hidden" value="'.$line->id.'">';
print '<input name="qtyl'.$i.'" type="text" size="6" value="'.$quantite_a_livrer.'">';
print '</td>';
}
print "</tr>\n";
$i++;
$var=!$var;
}
/*
*
*/
print '<tr><td align="center" colspan="4"><br><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>';
print "</table>";
print '</form>';
}
else
{
dol_print_error($db);
}
}
else
/* *************************************************************************** */

View File

@ -116,13 +116,14 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se
else if($action==='save_composed_product')
{
$TProduct = GETPOST('TProduct', 'array');
if(!empty($TProduct))
if (!empty($TProduct))
{
foreach ($TProduct as $id_product => $row)
{
if ($row['qty'] > 0) $object->update_sousproduit($id, $id_product, $row['qty'], isset($row['incdec']) ? 1 : 0 );
else $object->del_sousproduit($id, $id_product);
}
setEventMessages('RecordSaved', null);
}
$action='';
}

View File

@ -664,10 +664,11 @@ if ($resql)
else print $langs->trans('PrivateProject');
print '</td>';
}
// Amount
if (! empty($arrayfields['p.opp_amount']['checked']))
{
print '<td align="right">';
if ($obj->opp_status_code) print price($obj->opp_amount, 1, '', 1, -1, -1, $conf->currency);
if ($obj->opp_status_code) print price($obj->opp_amount, 1, '', 1, -1, -1, '');
print '</td>';
}
if (! empty($arrayfields['p.fk_opp_status']['checked']))