';
- if($isCustomer) {
+ if ($isCustomer) {
// Customer discount
print '| ';
print $langs->trans("CustomerRelativeDiscount").' | '.price2num($object->remise_percent)."% |
";
}
- if($isSupplier) {
+ if ($isSupplier) {
// Supplier discount
print '| ';
print $langs->trans("SupplierRelativeDiscount").' | '.price2num($object->remise_supplier_percent)."% |
";
@@ -155,21 +155,28 @@ if ($socid > 0)
print '';
- if($isCustomer && ! $isSupplier) {
- print '';
- }
-
- if(! $isCustomer && $isSupplier) {
- print '';
- }
+ /*if (! ($isCustomer && $isSupplier))
+ {
+ if ($isCustomer && ! $isSupplier) {
+ print '';
+ }
+ if (! $isCustomer && $isSupplier) {
+ print '';
+ }
+ }*/
print '';
- if($isCustomer && $isSupplier) {
+ if ($isCustomer || $isSupplier)
+ {
// Discount type
- print '| '.$langs->trans('DiscountType').' | ';
- print ' ';
- print ' ';
+ print ' |
| '.$langs->trans('DiscountType').' | ';
+ if ($isCustomer) {
+ print ' ';
+ }
+ if ($isSupplier) {
+ print ' ';
+ }
print ' |
';
}
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 0b0348ee5e0..66f01399183 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -662,7 +662,7 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@@ -1023,7 +1023,7 @@ if (empty($reshook))
// Extrafields Lines
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
// Unset extrafield POST Data
if (is_array($extralabelsline)) {
foreach ($extralabelsline as $key => $value) {
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index db497733863..81a0f3f9156 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -638,11 +638,12 @@ else
print '| '.$langs->trans("AccountancyJournal").' | ';
print '';
- $accountingjournal = new AccountingJournal($db);
- $accountingjournal->fetch($object->fk_accountancy_journal);
-
- print $accountingjournal->getNomUrl(0,1,1,'',1);
+ if ($object->fk_accountancy_journal > 0) {
+ $accountingjournal = new AccountingJournal($db);
+ $accountingjournal->fetch($object->fk_accountancy_journal);
+ print $accountingjournal->getNomUrl(0, 1, 1, '', 1);
+ }
print ' |
';
}
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 6568ac03eba..cc58f1e6dec 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1290,15 +1290,15 @@ if (empty($reshook))
$qualified=1;
if (empty($lines[$i]->qty)) $qualified=0; // We discard qty=0, it is an option
if (! empty($lines[$i]->special_code)) $qualified=0; // We discard special_code (frais port, ecotaxe, option, ...)
- if ($qualified) $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ?
+ if ($qualified){
+ $totalamount += $lines[$i]->total_ht; // Fixme : is it not for the customer ? Shouldn't we take total_ttc ?
+ $tva_tx = $lines[$i]->tva_tx;
+ $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * $valuedeposit) / 100;
+ }
+
}
- if ($totalamount != 0) {
- if ($numlines > 0) $numlines = $numlines-1;
- $tva_tx = $lines[$numlines]->tva_tx;
- if (! empty($lines[$numlines]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$numlines]->vat_src_code.')';
- $amountdeposit[$tva_tx] = ($totalamount * $valuedeposit) / 100;
- } else {
+ if($totalamount == 0) {
$amountdeposit[0] = 0;
}
} else {
@@ -1309,9 +1309,10 @@ if (empty($reshook))
$amount_ttc_diff = $amountdeposit[0];
}
-
foreach ($amountdeposit as $tva => $amount)
{
+ if (empty($amount)) continue;
+
$arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
$descline = $langs->trans('Deposit');
//$descline.= ' - '.$langs->trans($arraylist[$typeamount]);
@@ -1320,6 +1321,7 @@ if (empty($reshook))
} elseif ($typeamount=='variable') {
$descline.= ' ('. $valuedeposit.'%)';
}
+
$descline.= ' - '.$srcobject->ref;
$result = $object->addline(
$descline,
@@ -1682,7 +1684,7 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@@ -2089,7 +2091,7 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index a6e979cdd10..d303e6edf21 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1605,7 +1605,7 @@ class Facture extends CommonInvoice
$sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null").",";
$sql.= " situation_cycle_ref=".(empty($this->situation_cycle_ref)?"null":$this->db->escape($this->situation_cycle_ref)).",";
$sql.= " situation_counter=".(empty($this->situation_counter)?"null":$this->db->escape($this->situation_counter)).",";
- $sql.= " situation_final=".(empty($this->situation_counter)?"0":$this->db->escape($this->situation_counter));
+ $sql.= " situation_final=".(empty($this->situation_final)?"0":$this->db->escape($this->situation_final));
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index fb70da42665..36c1aec55b9 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -453,7 +453,7 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline))
{
@@ -776,7 +776,7 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$objectline = new FactureLigneRec($db);
if ($objectline->fetch(GETPOST('lineid')))
diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php
index ae95d71ca9c..f09ee172a40 100644
--- a/htdocs/compta/tva/clients.php
+++ b/htdocs/compta/tva/clients.php
@@ -372,161 +372,156 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$subtot_coll_total_ht = 0;
$subtot_coll_vat = 0;
- if (is_array($x_both[$thirdparty_id]['coll']['detail']))
- {
+ if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) {
- // VAT Rate
- print "";
- print '| ';
- if (is_numeric($thirdparty_id))
- {
- $company_static->fetch($thirdparty_id);
- print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1);
- }
- else
- {
- $tmpid = preg_replace('/userid_/','',$thirdparty_id);
- $user_static->fetch($tmpid);
- print $langs->trans("User").': '.$user_static->getNomUrl(1);
- }
- print ' | | ';
- print '
'."\n";
+ if (is_array($x_both[$thirdparty_id]['coll']['detail'])) {
- foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) {
- // Define type
- // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
- $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
- if (!empty($fields['ddate_start'])) {
- $type=1;
- }
- if (!empty($fields['ddate_end'])) {
- $type=1;
+ // VAT Rate
+ print "";
+ print '| ';
+ if (is_numeric($thirdparty_id)) {
+ $company_static->fetch($thirdparty_id);
+ print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
+ } else {
+ $tmpid = preg_replace('/userid_/', '', $thirdparty_id);
+ $user_static->fetch($tmpid);
+ print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
}
+ print ' | | ';
+ print '
' . "\n";
-
- print '';
-
- // Ref
- print '| '.$fields['link'].' | ';
-
- // Invoice date
- print '' . dol_print_date($fields['datef'], 'day') . ' | ';
-
- // Payment date
- if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '' . dol_print_date($fields['datep'], 'day') . ' | ';
- else print ' | ';
-
- // Rate
- print '' . $fields['drate'] . ' | ';
-
- // Description
- print '';
- if ($fields['pid'])
- {
- $product_static->id=$fields['pid'];
- $product_static->ref=$fields['pref'];
- $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
- print $product_static->getNomUrl(1);
- if (dol_string_nohtmltag($fields['descr'])) {
- print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
+ foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) {
+ // Define type
+ // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
+ $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
+ // Try to enhance type detection using date_start and date_end for free lines where type
+ // was not saved.
+ if (!empty($fields['ddate_start'])) {
+ $type = 1;
}
- }
- else
- {
- if ($type) {
- $text = img_object($langs->trans('Service'),'service');
+ if (!empty($fields['ddate_end'])) {
+ $type = 1;
+ }
+
+
+ print ' |
';
+
+ // Ref
+ print '| ' . $fields['link'] . ' | ';
+
+ // Invoice date
+ print '' . dol_print_date($fields['datef'], 'day') . ' | ';
+
+ // Payment date
+ if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
+ print '' . dol_print_date($fields['datep'], 'day') . ' | ';
} else {
- $text = img_object($langs->trans('Product'),'product');
+ print ' | ';
}
- if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
- if ($reg[1]=='DEPOSIT') {
- $fields['descr']=$langs->transnoentitiesnoconv('Deposit');
- } elseif ($reg[1]=='CREDIT_NOTE') {
- $fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
+
+ // Rate
+ print '' . $fields['drate'] . ' | ';
+
+ // Description
+ print '';
+ if ($fields['pid']) {
+ $product_static->id = $fields['pid'];
+ $product_static->ref = $fields['pref'];
+ $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
+ print $product_static->getNomUrl(1);
+ if (dol_string_nohtmltag($fields['descr'])) {
+ print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
+ }
+ } else {
+ if ($type) {
+ $text = img_object($langs->trans('Service'), 'service');
} else {
- $fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
+ $text = img_object($langs->trans('Product'), 'product');
}
- }
- print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
+ if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) {
+ if ($reg[1] == 'DEPOSIT') {
+ $fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
+ } elseif ($reg[1] == 'CREDIT_NOTE') {
+ $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
+ } else {
+ $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
+ }
+ }
+ print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
- // Show range
- print_date_range($fields['ddate_start'],$fields['ddate_end']);
- }
- print ' | ';
-
- // Total HT
- if ($modetax != 1)
- {
- print '';
- print price($fields['totalht']);
- if (price2num($fields['ftotal_ttc']))
- {
- //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
- $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
- //print ' ('.round($ratiolineinvoice*100,2).'%)';
+ // Show range
+ print_date_range($fields['ddate_start'], $fields['ddate_end']);
}
print ' | ';
- }
- // Payment
- $ratiopaymentinvoice=1;
- if ($modetax != 1)
- {
+ // Total HT
+ if ($modetax != 1) {
+ print '';
+ print price($fields['totalht']);
+ if (price2num($fields['ftotal_ttc'])) {
+ //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
+ $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
+ //print ' ('.round($ratiolineinvoice*100,2).'%)';
+ }
+ print ' | ';
+ }
+
+ // Payment
+ $ratiopaymentinvoice = 1;
+ if ($modetax != 1) {
+ print '';
+ //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
+ if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
+ $payment_static->id = $fields['payment_id'];
+ print $payment_static->getNomUrl(2);
+ }
+ if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
+ || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) {
+ print $langs->trans("NA");
+ } else {
+ if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
+ $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
+ }
+ print price(price2num($fields['payment_amount'], 'MT'));
+ if (isset($fields['payment_amount'])) {
+ print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)';
+ }
+ }
+ print ' | ';
+ }
+
+ // Total collected
print '';
- //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
- if ($fields['payment_amount'] && $fields['ftotal_ttc'])
- {
- $payment_static->id=$fields['payment_id'];
- print $payment_static->getNomUrl(2);
- }
- if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
- || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
- {
- print $langs->trans("NA");
- } else {
- if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
- $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
- }
- print price(price2num($fields['payment_amount'],'MT'));
- if (isset($fields['payment_amount'])) {
- print ' ('.round($ratiopaymentinvoice*100,2).'%)';
- }
- }
+ $temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
+ print price(price2num($temp_ht, 'MT'), 1);
print ' | ';
+
+ // VAT
+ print '';
+ $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
+ print price(price2num($temp_vat, 'MT'), 1);
+ //print price($fields['vat']);
+ print ' | ';
+ print '
';
+
+ $subtot_coll_total_ht += $temp_ht;
+ $subtot_coll_vat += $temp_vat;
+ $x_coll_sum += $temp_vat;
}
- // Total collected
- print '';
- $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
- print price(price2num($temp_ht,'MT'),1);
- print ' | ';
-
- // VAT
- print '';
- $temp_vat=$fields['vat']*$ratiopaymentinvoice;
- print price(price2num($temp_vat,'MT'),1);
- //print price($fields['vat']);
- print ' | ';
- print '';
-
- $subtot_coll_total_ht += $temp_ht;
- $subtot_coll_vat += $temp_vat;
- $x_coll_sum += $temp_vat;
}
+ // Total customers for this vat rate
+ print '';
+ print ' | ';
+ print '' . $langs->trans("Total") . ': | ';
+ if ($modetax != 1) {
+ print ' | ';
+ print ' | ';
+ }
+ print '' . price(price2num($subtot_coll_total_ht, 'MT')) . ' | ';
+ print '' . price(price2num($subtot_coll_vat, 'MT')) . ' | ';
+ print '
';
}
- // Total customers for this vat rate
- print '';
- print ' | ';
- print ''.$langs->trans("Total").': | ';
- if ($modetax != 1) {
- print ' | ';
- print ' | ';
- }
- print ''.price(price2num($subtot_coll_total_ht,'MT')).' | ';
- print ''.price(price2num($subtot_coll_vat,'MT')).' | ';
- print '
';
}
if (count($x_coll) == 0) // Show a total ine if nothing shown
@@ -567,161 +562,153 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$subtot_paye_total_ht = 0;
$subtot_paye_vat = 0;
- if (is_array($x_both[$thirdparty_id]['paye']['detail']))
- {
- print "";
- print '| ';
- if (is_numeric($thirdparty_id))
- {
- $company_static->fetch($thirdparty_id);
- print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1);
- }
- else
- {
- $tmpid = preg_replace('/userid_/','',$thirdparty_id);
- $user_static->fetch($tmpid);
- print $langs->trans("User").': '.$user_static->getNomUrl(1);
- }
- print ' | | ';
- print '
'."\n";
+ if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) {
- foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index=>$fields) {
- // Define type
- // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
- $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
- if (!empty($fields['ddate_start'])) {
- $type=1;
- }
- if (!empty($fields['ddate_end'])) {
- $type=1;
+ if (is_array($x_both[$thirdparty_id]['paye']['detail'])) {
+ print "";
+ print '| ';
+ if (is_numeric($thirdparty_id)) {
+ $company_static->fetch($thirdparty_id);
+ print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
+ } else {
+ $tmpid = preg_replace('/userid_/', '', $thirdparty_id);
+ $user_static->fetch($tmpid);
+ print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
}
+ print ' | | ';
+ print '
' . "\n";
-
- print '';
-
- // Ref
- print '| '.$fields['link'].' | ';
-
- // Invoice date
- print '' . dol_print_date($fields['datef'], 'day') . ' | ';
-
- // Payment date
- if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '' . dol_print_date($fields['datep'], 'day') . ' | ';
- else print ' | ';
-
- // Company name
- print '' . $fields['company_link'] . ' | ';
-
- // Description
- print '';
- if ($fields['pid'])
- {
- $product_static->id=$fields['pid'];
- $product_static->ref=$fields['pref'];
- $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
- print $product_static->getNomUrl(1);
- if (dol_string_nohtmltag($fields['descr'])) {
- print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
+ foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index => $fields) {
+ // Define type
+ // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
+ $type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
+ // Try to enhance type detection using date_start and date_end for free lines where type
+ // was not saved.
+ if (!empty($fields['ddate_start'])) {
+ $type = 1;
}
- }
- else
- {
- if ($type) {
- $text = img_object($langs->trans('Service'),'service');
+ if (!empty($fields['ddate_end'])) {
+ $type = 1;
+ }
+
+
+ print ' |
';
+
+ // Ref
+ print '| ' . $fields['link'] . ' | ';
+
+ // Invoice date
+ print '' . dol_print_date($fields['datef'], 'day') . ' | ';
+
+ // Payment date
+ if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') {
+ print '' . dol_print_date($fields['datep'], 'day') . ' | ';
} else {
- $text = img_object($langs->trans('Product'),'product');
+ print ' | ';
}
- if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
- if ($reg[1]=='DEPOSIT') {
- $fields['descr']=$langs->transnoentitiesnoconv('Deposit');
- } elseif ($reg[1]=='CREDIT_NOTE') {
- $fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
+
+ // Company name
+ print '' . $fields['company_link'] . ' | ';
+
+ // Description
+ print '';
+ if ($fields['pid']) {
+ $product_static->id = $fields['pid'];
+ $product_static->ref = $fields['pref'];
+ $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
+ print $product_static->getNomUrl(1);
+ if (dol_string_nohtmltag($fields['descr'])) {
+ print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
+ }
+ } else {
+ if ($type) {
+ $text = img_object($langs->trans('Service'), 'service');
} else {
- $fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
+ $text = img_object($langs->trans('Product'), 'product');
}
- }
- print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
+ if (preg_match('/^\((.*)\)$/', $fields['descr'], $reg)) {
+ if ($reg[1] == 'DEPOSIT') {
+ $fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
+ } elseif ($reg[1] == 'CREDIT_NOTE') {
+ $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
+ } else {
+ $fields['descr'] = $langs->transnoentitiesnoconv($reg[1]);
+ }
+ }
+ print $text . ' ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
- // Show range
- print_date_range($fields['ddate_start'],$fields['ddate_end']);
- }
- print ' | ';
-
- // Total HT
- if ($modetax != 1)
- {
- print '';
- print price($fields['totalht']);
- if (price2num($fields['ftotal_ttc']))
- {
- //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
- $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
- //print ' ('.round($ratiolineinvoice*100,2).'%)';
+ // Show range
+ print_date_range($fields['ddate_start'], $fields['ddate_end']);
}
print ' | ';
- }
- // Payment
- $ratiopaymentinvoice=1;
- if ($modetax != 1)
- {
+ // Total HT
+ if ($modetax != 1) {
+ print '';
+ print price($fields['totalht']);
+ if (price2num($fields['ftotal_ttc'])) {
+ //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
+ $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
+ //print ' ('.round($ratiolineinvoice*100,2).'%)';
+ }
+ print ' | ';
+ }
+
+ // Payment
+ $ratiopaymentinvoice = 1;
+ if ($modetax != 1) {
+ print '';
+ if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
+ $paymentfourn_static->id = $fields['payment_id'];
+ print $paymentfourn_static->getNomUrl(2);
+ }
+
+ if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
+ || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) {
+ print $langs->trans("NA");
+ } else {
+ if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
+ $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
+ }
+ print price(price2num($fields['payment_amount'], 'MT'));
+ if (isset($fields['payment_amount'])) {
+ print ' (' . round($ratiopaymentinvoice * 100, 2) . '%)';
+ }
+ }
+ print ' | ';
+ }
+
+ // VAT paid
print '';
- if ($fields['payment_amount'] && $fields['ftotal_ttc'])
- {
- $paymentfourn_static->id=$fields['payment_id'];
- print $paymentfourn_static->getNomUrl(2);
- }
-
- if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
- || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice'))
- {
- print $langs->trans("NA");
- }
- else
- {
- if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
- $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
- }
- print price(price2num($fields['payment_amount'],'MT'));
- if (isset($fields['payment_amount'])) {
- print ' ('.round($ratiopaymentinvoice*100,2).'%)';
- }
- }
+ $temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
+ print price(price2num($temp_ht, 'MT'), 1);
print ' | ';
+
+ // VAT
+ print '';
+ $temp_vat = $fields['vat'] * $ratiopaymentinvoice;
+ print price(price2num($temp_vat, 'MT'), 1);
+ //print price($fields['vat']);
+ print ' | ';
+ print '
';
+
+ $subtot_paye_total_ht += $temp_ht;
+ $subtot_paye_vat += $temp_vat;
+ $x_paye_sum += $temp_vat;
}
-
- // VAT paid
- print '';
- $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
- print price(price2num($temp_ht,'MT'),1);
- print ' | ';
-
- // VAT
- print '';
- $temp_vat=$fields['vat']*$ratiopaymentinvoice;
- print price(price2num($temp_vat,'MT'),1);
- //print price($fields['vat']);
- print ' | ';
- print '';
-
- $subtot_paye_total_ht += $temp_ht;
- $subtot_paye_vat += $temp_vat;
- $x_paye_sum += $temp_vat;
}
+ // Total suppliers for this vat rate
+ print '';
+ print ' | ';
+ print '' . $langs->trans("Total") . ': | ';
+ if ($modetax != 1) {
+ print ' | ';
+ print ' | ';
+ }
+ print '' . price(price2num($subtot_paye_total_ht, 'MT')) . ' | ';
+ print '' . price(price2num($subtot_paye_vat, 'MT')) . ' | ';
+ print '
';
}
- // Total suppliers for this vat rate
- print '';
- print ' | ';
- print ''.$langs->trans("Total").': | ';
- if ($modetax != 1) {
- print ' | ';
- print ' | ';
- }
- print ''.price(price2num($subtot_paye_total_ht,'MT')).' | ';
- print ''.price(price2num($subtot_paye_vat,'MT')).' | ';
- print '
';
}
if (count($x_paye) == 0) { // Show a total line if nothing shown
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 5f418cb0568..b681e8147a7 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -456,7 +456,7 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@@ -737,7 +737,7 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
- $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
+ $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$objectline->array_options=$array_options;
// TODO verifier price_min si fk_product et multiprix
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index dc94d57809f..2b9de7fc9e2 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -892,6 +892,7 @@ class Contrat extends CommonObject
$sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL");
$sql.= ")";
$resql=$this->db->query($sql);
+
if ($resql)
{
$error=0;
@@ -908,9 +909,8 @@ class Contrat extends CommonObject
if ($result > 0)
{
$modCodeContract = new $module();
-
- if (!empty($modCodeContract->code_auto)) {
- // Mise a jour ref
+ if (! empty($modCodeContract->code_auto)) {
+ // Force the ref to a draft value if numbering module is an automatic numbering
$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
@@ -919,9 +919,6 @@ class Contrat extends CommonObject
$this->ref="(PROV".$this->id.")";
}
}
- } else {
- $error++;
- $this->error='Failed to get PROV number';
}
}
@@ -1389,7 +1386,7 @@ class Contrat extends CommonObject
if (empty($remise_percent)) $remise_percent=0;
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
-
+
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
@@ -1397,7 +1394,7 @@ class Contrat extends CommonObject
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
-
+
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 33eeda9f4b2..f7208111d7a 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -519,7 +519,7 @@ if ($massaction == 'confirm_createbills')
else {
// Load extrafields of order
$cmd->fetch_optionals();
-
+
$objecttmp->socid = $cmd->socid;
$objecttmp->type = Facture::TYPE_STANDARD;
$objecttmp->cond_reglement_id = $cmd->cond_reglement_id;
@@ -577,6 +577,12 @@ if ($massaction == 'confirm_createbills')
for ($i=0;$i<$num;$i++)
{
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
+ // If we build one invoice for several order, we must put the invoice of order on the line
+ if (! empty($createbills_onebythird))
+ {
+ $desc=dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs));
+ }
+
if ($lines[$i]->subprice < 0)
{
// Negative line, we create a discount line
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 676e76fe16a..f0fe7bf437c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4932,8 +4932,6 @@ abstract class CommonObject
$new_array_options[$key] = price2num($this->array_options[$key]);
break;
case 'date':
- $new_array_options[$key] = $this->db->idate($this->array_options[$key]);
- break;
case 'datetime':
// If data is a string instead of a timestamp, we convert it
if (! is_int($this->array_options[$key])) {
@@ -4981,8 +4979,9 @@ abstract class CommonObject
$table_element = $this->table_element;
if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility
+ dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG);
+
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id;
- dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
$this->db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object";
@@ -4993,6 +4992,17 @@ abstract class CommonObject
if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator
$sql.=",".$attributeKey;
}
+ // We must insert a default value for fields for other entities that are mandatory to avoid not null error
+ if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']))
+ {
+ foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
+ {
+ if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
+ {
+ $sql.=",".$tmpkey;
+ }
+ }
+ }
$sql .= ") VALUES (".$this->id;
foreach($new_array_options as $key => $value)
@@ -5011,10 +5021,23 @@ abstract class CommonObject
}
}
}
+ // We must insert a default value for fields for other entities that are mandatory to avoid not null error
+ if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']))
+ {
+ foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
+ {
+ if (! isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
+ {
+ if (in_array($tmpval, array('int', 'double'))) $sql.=", 0";
+ else $sql.=", ''";
+ }
+ }
+ }
+
$sql.=")";
- dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG);
$resql = $this->db->query($sql);
+
if (! $resql)
{
$this->error=$this->db->lasterror();
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 48eabbefe9e..f8ae333935e 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -747,7 +747,7 @@ class ExtraFields
* @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required.
* @return array Array of attributes keys+label for all extra fields.
*/
- function fetch_name_optionals_label($elementtype,$forceload=false)
+ function fetch_name_optionals_label($elementtype, $forceload=false)
{
global $conf;
@@ -783,8 +783,8 @@ class ExtraFields
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
- $sql.= " WHERE entity IN (0,".$conf->entity.")";
- if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element
+ //$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
+ if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element
$sql.= " ORDER BY pos";
$resql=$this->db->query($sql);
@@ -794,6 +794,16 @@ class ExtraFields
{
while ($tab = $this->db->fetch_object($resql))
{
+ if ($tab->entity != 0 && $tab->entity != $conf->entity)
+ {
+ // This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field without default value
+ if ($tab->fieldrequired && is_null($tab->fielddefault))
+ {
+ $this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type;
+ }
+ continue;
+ }
+
// We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label']
if ($tab->type != 'separate')
{
@@ -1515,7 +1525,7 @@ class ExtraFields
}
elseif ($type == 'phone')
{
- $value=dol_print_phone($value, '', 0, 0, '', ' ', 1);
+ $value=dol_print_phone($value, '', 0, 0, '', ' ', 'phone');
}
elseif ($type == 'price')
{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 58df0ad4e22..8f0af0a5004 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3324,7 +3324,10 @@ class Form
$langs->load('bills');
$opt = '';
- $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1';
+ $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc';
+ $sql.= ' FROM ' . MAIN_DB_PREFIX . 'facture';
+ $sql.= ' WHERE entity IN ('.getEntity('facture').')';
+ $sql.= ' AND situation_counter>=1';
$sql.= ' ORDER by situation_cycle_ref, situation_counter desc';
$resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) {
@@ -4517,7 +4520,7 @@ class Form
$out='';
$out.= '
";
print '';
@@ -2140,298 +2152,305 @@ else if ($id || $ref)
// Loop on each product to send/sent
for ($i = 0 ; $i < $num_prod ; $i++)
{
- print ''; // id of order line
- print '';
+ $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => $editColspan, 'outputlangs' => $outputlangs);
+ $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
+ if($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- // #
- if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
+ if(empty($reshook))
{
- print '| '.($i+1).' | ';
- }
+ print ''; // id of order line
+ print '
';
- // Predefined product or service
- if ($lines[$i]->fk_product > 0)
- {
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ // #
+ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
{
- $prod = new Product($db);
- $prod->fetch($lines[$i]->fk_product);
- $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label;
+ print '| '.($i+1).' | ';
+ }
+
+ // Predefined product or service
+ if ($lines[$i]->fk_product > 0)
+ {
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ {
+ $prod = new Product($db);
+ $prod->fetch($lines[$i]->fk_product);
+ $label = ( ! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label;
+ }
+ else
+ $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label);
+
+ print '';
+
+ // Show product and description
+ $product_static->type=$lines[$i]->fk_product_type;
+ $product_static->id=$lines[$i]->fk_product;
+ $product_static->ref=$lines[$i]->ref;
+ $product_static->status_batch=$lines[$i]->product_tobatch;
+ $text=$product_static->getNomUrl(1);
+ $text.= ' - '.$label;
+ $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description));
+ print $form->textwithtooltip($text,$description,3,'','',$i);
+ print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?' '.dol_htmlentitiesbr($lines[$i]->description):'';
+ }
+ print " | \n";
}
else
- $label = (! empty($lines[$i]->label)?$lines[$i]->label:$lines[$i]->product_label);
-
- print '';
-
- // Show product and description
- $product_static->type=$lines[$i]->fk_product_type;
- $product_static->id=$lines[$i]->fk_product;
- $product_static->ref=$lines[$i]->ref;
- $product_static->status_batch=$lines[$i]->product_tobatch;
- $text=$product_static->getNomUrl(1);
- $text.= ' - '.$label;
- $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($lines[$i]->description));
- print $form->textwithtooltip($text,$description,3,'','',$i);
- print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
- print (! empty($lines[$i]->description) && $lines[$i]->description!=$lines[$i]->product)?' '.dol_htmlentitiesbr($lines[$i]->description):'';
- }
- print " | \n";
- }
- else
- {
- print "";
- if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
+ print " | ";
+ if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
- if (! empty($lines[$i]->label)) {
- $text.= ' '.$lines[$i]->label.'';
- print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i);
- } else {
- print $text.' '.nl2br($lines[$i]->description);
- }
-
- print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
- print " | \n";
- }
-
- // Qty ordered
- print ''.$lines[$i]->qty_asked.' | ';
-
- // Qty in other shipments (with shipment and warehouse used)
- if ($origin && $origin_id > 0)
- {
- print '';
- foreach ($alreadysent as $key => $val)
- {
- if ($lines[$i]->fk_origin_line == $key)
- {
- $j = 0;
- foreach($val as $shipmentline_id=> $shipmentline_var)
- {
- if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments"
-
- $j++;
- if ($j > 1) print ' ';
- $shipment_static->fetch($shipmentline_var['shipment_id']);
- print $shipment_static->getNomUrl(1);
- print ' - '.$shipmentline_var['qty_shipped'];
- $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour'));
- if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0)
- {
- $warehousestatic->fetch($shipmentline_var['warehouse']);
- $htmltext .= ' '.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1);
- }
- print ' '.$form->textwithpicto('', $htmltext, 1);
- }
- }
- }
- }
- print ' | ';
-
- if ($action == 'editline' && $lines[$i]->id == $line_id)
- {
- // edit mode
- print '';
- if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
- {
- print '';
- $line = new ExpeditionLigne($db);
- foreach ($lines[$i]->detail_batch as $detail_batch)
- {
- print '';
- // Qty to ship or shipped
- print '| ' . '' . ' | ';
- // Batch number managment
- if ($lines[$i]->entrepot_id == 0)
- {
- // only show lot numbers from src warehouse when shipping from multiple warehouses
- $line->fetch($detail_batch->fk_expeditiondet);
- }
- print '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). ' | ';
- print ' ';
+ if (! empty($lines[$i]->label)) {
+ $text.= ' '.$lines[$i]->label.'';
+ print $form->textwithtooltip($text,$lines[$i]->description,3,'','',$i);
+ } else {
+ print $text.' '.nl2br($lines[$i]->description);
}
- // add a 0 qty lot row to be able to add a lot
- print '';
- // Qty to ship or shipped
- print '| ' . '' . ' | ';
- // Batch number managment
- print '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). ' | ';
- print ' ';
+
+ print_date_range($lines[$i]->date_start,$lines[$i]->date_end);
+ print "\n";
}
- else if (! empty($conf->stock->enabled))
+
+ // Qty ordered
+ print ''.$lines[$i]->qty_asked.' | ';
+
+ // Qty in other shipments (with shipment and warehouse used)
+ if ($origin && $origin_id > 0)
+ {
+ print '';
+ foreach ($alreadysent as $key => $val)
+ {
+ if ($lines[$i]->fk_origin_line == $key)
+ {
+ $j = 0;
+ foreach($val as $shipmentline_id=> $shipmentline_var)
+ {
+ if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) continue; // We want to show only "other shipments"
+
+ $j++;
+ if ($j > 1) print ' ';
+ $shipment_static->fetch($shipmentline_var['shipment_id']);
+ print $shipment_static->getNomUrl(1);
+ print ' - '.$shipmentline_var['qty_shipped'];
+ $htmltext=$langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid'])?$langs->trans("Draft"):dol_print_date($shipmentline_var['date_valid'], 'dayhour'));
+ if (! empty($conf->stock->enabled) && $shipmentline_var['warehouse'] > 0)
+ {
+ $warehousestatic->fetch($shipmentline_var['warehouse']);
+ $htmltext .= ' '.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1);
+ }
+ print ' '.$form->textwithpicto('', $htmltext, 1);
+ }
+ }
+ }
+ }
+ print ' | ';
+
+ if ($action == 'editline' && $lines[$i]->id == $line_id)
{
- if ($lines[$i]->fk_product > 0)
+ // edit mode
+ print '';
+ if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0)
{
- if ($lines[$i]->entrepot_id > 0)
+ print '';
+ $line = new ExpeditionLigne($db);
+ foreach ($lines[$i]->detail_batch as $detail_batch)
{
- print '';
print '';
// Qty to ship or shipped
- print '| ' . '' . ' | ';
- // Warehouse source
- print '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). ' | ';
+ print '' . '' . ' | ';
// Batch number managment
- print ' - ' . $langs->trans("NA") . ' | ';
+ if ($lines[$i]->entrepot_id == 0)
+ {
+ // only show lot numbers from src warehouse when shipping from multiple warehouses
+ $line->fetch($detail_batch->fk_expeditiondet);
+ }
+ print '' . $formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id). ' | ';
print ' ';
}
- else if (count($lines[$i]->details_entrepot) > 1)
+ // add a 0 qty lot row to be able to add a lot
+ print '';
+ // Qty to ship or shipped
+ print '| ' . '' . ' | ';
+ // Batch number managment
+ print '' . $formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product). ' | ';
+ print ' ';
+ }
+ else if (! empty($conf->stock->enabled))
+ {
+ if ($lines[$i]->fk_product > 0)
{
- print '';
- foreach ($lines[$i]->details_entrepot as $detail_entrepot)
+ if ($lines[$i]->entrepot_id > 0)
{
+ print '';
print '';
// Qty to ship or shipped
- print '| ' . '' . ' | ';
+ print '' . '' . ' | ';
// Warehouse source
- print '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . ' | ';
+ print '' . $formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1). ' | ';
// Batch number managment
print ' - ' . $langs->trans("NA") . ' | ';
print ' ';
}
+ else if (count($lines[$i]->details_entrepot) > 1)
+ {
+ print '';
+ foreach ($lines[$i]->details_entrepot as $detail_entrepot)
+ {
+ print '';
+ // Qty to ship or shipped
+ print '| ' . '' . ' | ';
+ // Warehouse source
+ print '' . $formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1) . ' | ';
+ // Batch number managment
+ print ' - ' . $langs->trans("NA") . ' | ';
+ print ' ';
+ }
+ }
+ else
+ {
+ print '';
+ print '| '.$langs->trans("NotEnoughStock").' | ';
+ }
}
else
{
- print '';
- print '| '.$langs->trans("NotEnoughStock").' | ';
+ print '';
+ print '';
+ // Qty to ship or shipped
+ print '| ' . '' . ' | ';
+ // Warehouse source
+ print '' . ' | ';
+ // Batch number managment
+ print '' . ' | ';
+ print ' ';
}
}
- else
- {
- print '';
- print '';
- // Qty to ship or shipped
- print '| ' . '' . ' | ';
- // Warehouse source
- print '' . ' | ';
- // Batch number managment
- print '' . ' | ';
- print ' ';
- }
- }
- print ' | ';
- }
- else
- {
- // Qty to ship or shipped
- print ''.$lines[$i]->qty_shipped.' | ';
-
- // Warehouse source
- if (! empty($conf->stock->enabled))
- {
- print '';
- if ($lines[$i]->entrepot_id > 0)
- {
- $entrepot = new Entrepot($db);
- $entrepot->fetch($lines[$i]->entrepot_id);
- 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).' ';
- }
- }
- print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail);
- }
- print ' | ';
- }
-
- // Batch number managment
- if (! empty($conf->productbatch->enabled))
- {
- if (isset($lines[$i]->detail_batch))
- {
- print '';
- print '';
- if ($lines[$i]->product_tobatch)
- {
- $detail = '';
- foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch
- {
- $detail.= $langs->trans("Batch").': '.$dbatch->batch;
- $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
- $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
- $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
- $detail.= ' ';
- }
- print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
- }
- else
- {
- print $langs->trans("NA");
- }
- print ' | ';
- } else {
- print ' | ';
- }
- }
- }
-
- // Weight
- print '';
- if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight");
- else print ' ';
- print ' | ';
-
- // Volume
- print '';
- if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume");
- else print ' ';
- print ' | ';
-
- // Size
- //print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").' | ';
-
- if ($action == 'editline' && $lines[$i]->id == $line_id)
- {
- print '';
- print ' ';
- print ' ';
- }
- else if ($object->statut == 0)
- {
- // edit-delete buttons
- print ' | ';
- print 'id . '&action=editline&lineid=' . $lines[$i]->id . '">' . img_edit() . '';
- print ' | ';
- print '';
- print 'id . '&action=deleteline&lineid=' . $lines[$i]->id . '">' . img_delete() . '';
- print ' | ';
-
- // Display lines extrafields
- if (! empty($rowExtrafieldsStart))
- {
- print $rowExtrafieldsStart;
- print $rowExtrafieldsView;
- print $rowEnd;
- }
- }
- print "";
-
- // Display lines extrafields
- if (is_array($extralabelslines) && count($extralabelslines)>0) {
- $colspan= empty($conf->productbatch->enabled) ? 5 : 6;
- $line = new ExpeditionLigne($db);
- $line->fetch_optionals($lines[$i]->id);
- print '';
- if ($action == 'editline' && $lines[$i]->id == $line_id)
- {
- print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ print ' | ';
}
else
{
- print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ // Qty to ship or shipped
+ print ''.$lines[$i]->qty_shipped.' | ';
+
+ // Warehouse source
+ if (! empty($conf->stock->enabled))
+ {
+ print '';
+ if ($lines[$i]->entrepot_id > 0)
+ {
+ $entrepot = new Entrepot($db);
+ $entrepot->fetch($lines[$i]->entrepot_id);
+ 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).' ';
+ }
+ }
+ print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"),$detail);
+ }
+ print ' | ';
+ }
+
+ // Batch number managment
+ if (! empty($conf->productbatch->enabled))
+ {
+ if (isset($lines[$i]->detail_batch))
+ {
+ print '';
+ print '';
+ if ($lines[$i]->product_tobatch)
+ {
+ $detail = '';
+ foreach ($lines[$i]->detail_batch as $dbatch) // $dbatch is instance of ExpeditionLineBatch
+ {
+ $detail.= $langs->trans("Batch").': '.$dbatch->batch;
+ $detail.= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby,"day");
+ $detail.= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby,"day");
+ $detail.= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
+ $detail.= ' ';
+ }
+ print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail);
+ }
+ else
+ {
+ print $langs->trans("NA");
+ }
+ print ' | ';
+ } else {
+ print ' | ';
+ }
+ }
+ }
+
+ // Weight
+ print '';
+ if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units,"weight");
+ else print ' ';
+ print ' | ';
+
+ // Volume
+ print '';
+ if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume");
+ else print ' ';
+ print ' | ';
+
+ // Size
+ //print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units,"volume").' | ';
+
+ if ($action == 'editline' && $lines[$i]->id == $line_id)
+ {
+ print '';
+ print ' ';
+ print ' ';
+ }
+ else if ($object->statut == 0)
+ {
+ // edit-delete buttons
+ print ' | ';
+ print 'id . '&action=editline&lineid=' . $lines[$i]->id . '">' . img_edit() . '';
+ print ' | ';
+ print '';
+ print 'id . '&action=deleteline&lineid=' . $lines[$i]->id . '">' . img_delete() . '';
+ print ' | ';
+
+ // Display lines extrafields
+ if (! empty($rowExtrafieldsStart))
+ {
+ print $rowExtrafieldsStart;
+ print $rowExtrafieldsView;
+ print $rowEnd;
+ }
+ }
+ print "
";
+
+ // Display lines extrafields
+ if (is_array($extralabelslines) && count($extralabelslines)>0) {
+ $colspan= empty($conf->productbatch->enabled) ? 5 : 6;
+ $line = new ExpeditionLigne($db);
+ $line->fetch_optionals($lines[$i]->id);
+ print '';
+ if ($action == 'editline' && $lines[$i]->id == $line_id)
+ {
+ print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ }
+ else
+ {
+ print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked);
+ }
+ print '
';
}
- print '';
}
}
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index cb058e44598..c92962357b2 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -42,6 +42,8 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) requi
// Load translation files required by the page
$langs->loadLangs(array('orders',"companies","bills",'propal','deliveries','stocks',"productbatch",'incoterm'));
+$hookmanager->initHooks(array('ordershipmentcard'));
+
$id=GETPOST('id','int'); // id of order
$ref= GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
@@ -613,6 +615,7 @@ if ($id > 0 || ! empty($ref))
$sql.= " cd.qty,";
$sql.= ' cd.date_start,';
$sql.= ' cd.date_end,';
+ $sql.= ' cd.special_code,';
$sql.= ' p.rowid as prodid, p.label as product_label, p.entity, p.ref, p.fk_product_type as product_type, p.description as product_desc';
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
@@ -648,164 +651,169 @@ if ($id > 0 || ! empty($ref))
{
$objp = $db->fetch_object($resql);
+ $parameters = array('i' => $i, 'line' => $objp, 'num' => $num);
+ $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action);
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- // Show product and description
- $type=isset($objp->type)?$objp->type:$objp->product_type;
-
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
- if (! empty($objp->date_start)) $type=1;
- if (! empty($objp->date_end)) $type=1;
-
- print '';
-
- // Product label
- if ($objp->fk_product > 0)
+ if(empty($reshook))
{
- // Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ // Show product and description
+ $type=isset($objp->type)?$objp->type:$objp->product_type;
+
+ // Try to enhance type detection using date_start and date_end for free lines where type
+ // was not saved.
+ if (! empty($objp->date_start)) $type=1;
+ if (! empty($objp->date_end)) $type=1;
+
+ print '
';
+
+ // Product label
+ if ($objp->fk_product > 0)
{
- $object->fetch_thirdparty();
-
- $prod = new Product($db);
- $prod->id = $objp->fk_product;
- $prod->entity = $objp->entity;
- $prod->getMultiLangs();
-
- $outputlangs = $langs;
- $newlang='';
- if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
- if (! empty($newlang))
+ // Define output language
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
- $outputlangs = new Translate("",$conf);
- $outputlangs->setDefaultLang($newlang);
+ $object->fetch_thirdparty();
+
+ $prod = new Product($db);
+ $prod->id = $objp->fk_product;
+ $prod->entity = $objp->entity;
+ $prod->getMultiLangs();
+
+ $outputlangs = $langs;
+ $newlang='';
+ if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
+ if (! empty($newlang))
+ {
+ $outputlangs = new Translate("",$conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+
+ $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
+ }
+ else
+ $label = (! empty($objp->label)?$objp->label:$objp->product_label);
+
+ print '';
+ print ''; // ancre pour retourner sur la ligne
+
+ // Show product and description
+ $product_static->type=$type;
+ $product_static->id=$objp->fk_product;
+ $product_static->ref=$objp->ref;
+ $product_static->entity = $objp->entity;
+ $text=$product_static->getNomUrl(1);
+ $text.= ' - '.$label;
+ $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).' ';
+ $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
+ print $form->textwithtooltip($text,$description,3,'','',$i);
+
+ // Show range
+ print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
+
+ // Add description in form
+ if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
+ {
+ print ($objp->description && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
}
- $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
+ print ' | ';
}
else
- $label = (! empty($objp->label)?$objp->label:$objp->product_label);
-
- print '';
- print ''; // ancre pour retourner sur la ligne
-
- // Show product and description
- $product_static->type=$type;
- $product_static->id=$objp->fk_product;
- $product_static->ref=$objp->ref;
- $product_static->entity = $objp->entity;
- $text=$product_static->getNomUrl(1);
- $text.= ' - '.$label;
- $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description)).' ';
- $description.= $product_static->show_photos('product', $conf->product->multidir_output[$product_static->entity], 1, 1, 0, 0, 0, 80);
- print $form->textwithtooltip($text,$description,3,'','',$i);
-
- // Show range
- print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
-
- // Add description in form
- if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
{
- print ($objp->description && $objp->description!=$objp->product_label)?' '.dol_htmlentitiesbr($objp->description):'';
+ print " | ";
+ if ($type==1) $text = img_object($langs->trans('Service'),'service');
+ else $text = img_object($langs->trans('Product'),'product');
+
+ if (! empty($objp->label)) {
+ $text.= ' '.$objp->label.'';
+ print $form->textwithtooltip($text,$objp->description,3,'','',$i);
+ } else {
+ print $text.' '.nl2br($objp->description);
+ }
+
+ // Show range
+ print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
+ print " | \n";
}
- print '';
- }
- else
- {
- print "";
- if ($type==1) $text = img_object($langs->trans('Service'),'service');
- else $text = img_object($langs->trans('Product'),'product');
+ // Qty ordered
+ print ' | ' . $objp->qty . ' | ';
- if (! empty($objp->label)) {
- $text.= ' '.$objp->label.'';
- print $form->textwithtooltip($text,$objp->description,3,'','',$i);
- } else {
- print $text.' '.nl2br($objp->description);
- }
-
- // Show range
- print_date_range($db->jdate($objp->date_start),$db->jdate($objp->date_end));
- print "\n";
- }
-
- // Qty ordered
- print '' . $objp->qty . ' | ';
-
- // Qty already shipped
- $qtyProdCom=$objp->qty;
- print '';
- // Nb of sending products for this line of order
- $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
- print $qtyAlreadyShipped;
- print ' | ';
-
- // Qty remains to ship
- print '';
- if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
- {
- $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
- $toBeShippedTotal += $toBeShipped[$objp->fk_product];
- print $toBeShipped[$objp->fk_product];
- }
- else
- {
- print '0 ('.$langs->trans("Service").')';
- }
- print ' | ';
-
- if ($objp->fk_product > 0)
- {
- $product = new Product($db);
- $product->fetch($objp->fk_product);
- $product->load_stock('warehouseopen');
- }
-
- if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled))
- {
+ // Qty already shipped
+ $qtyProdCom=$objp->qty;
print '';
- print $product->stock_reel;
- if ($product->stock_reel < $toBeShipped[$objp->fk_product])
+ // Nb of sending products for this line of order
+ $qtyAlreadyShipped = (! empty($object->expeditions[$objp->rowid])?$object->expeditions[$objp->rowid]:0);
+ print $qtyAlreadyShipped;
+ print ' | ';
+
+ // Qty remains to ship
+ print '';
+ if ($type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES))
{
- print ' '.img_warning($langs->trans("StockTooLow"));
+ $toBeShipped[$objp->fk_product] = $objp->qty - $qtyAlreadyShipped;
+ $toBeShippedTotal += $toBeShipped[$objp->fk_product];
+ print $toBeShipped[$objp->fk_product];
+ }
+ else
+ {
+ print '0 ('.$langs->trans("Service").')';
}
print ' | ';
- }
- else
- {
- print ' | ';
- }
- print "
\n";
- // Show subproducts lines
- if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
- {
- // Set tree of subproducts in product->sousprods
- $product->get_sousproduits_arbo();
- //var_dump($product->sousprods);exit;
-
- // Define a new tree with quantiies recalculated
- $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
- //var_dump($prods_arbo);
- if (count($prods_arbo) > 0)
+ if ($objp->fk_product > 0)
{
- foreach($prods_arbo as $key => $value)
+ $product = new Product($db);
+ $product->fetch($objp->fk_product);
+ $product->load_stock('warehouseopen');
+ }
+
+ if ($objp->fk_product > 0 && ($type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) && ! empty($conf->stock->enabled))
+ {
+ print '';
+ print $product->stock_reel;
+ if ($product->stock_reel < $toBeShipped[$objp->fk_product])
{
- $img='';
- if ($value['stock'] < $value['stock_alert'])
+ print ' '.img_warning($langs->trans("StockTooLow"));
+ }
+ print ' | ';
+ }
+ else
+ {
+ print ' | ';
+ }
+ print "\n";
+
+ // Show subproducts lines
+ if ($objp->fk_product > 0 && ! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ {
+ // Set tree of subproducts in product->sousprods
+ $product->get_sousproduits_arbo();
+ //var_dump($product->sousprods);exit;
+
+ // Define a new tree with quantiies recalculated
+ $prods_arbo = $product->get_arbo_each_prod($qtyProdCom);
+ //var_dump($prods_arbo);
+ if (count($prods_arbo) > 0)
+ {
+ foreach($prods_arbo as $key => $value)
{
- $img=img_warning($langs->trans("StockTooLow"));
+ $img='';
+ if ($value['stock'] < $value['stock_alert'])
+ {
+ $img=img_warning($langs->trans("StockTooLow"));
+ }
+ print '| -> '.$value['fullpath'].' ('.$value['nb'].') | ';
+ print ' '.$value['nb_total'].' | ';
+ print '  | ';
+ print '  | ';
+ print ''.$value['stock'].' '.$img.' |
'."\n";
}
- print '| -> '.$value['fullpath'].' ('.$value['nb'].') | ';
- print ' '.$value['nb_total'].' | ';
- print '  | ';
- print '  | ';
- print ''.$value['stock'].' '.$img.' |
'."\n";
}
}
}
-
$i++;
}
$db->free($resql);
@@ -886,7 +894,7 @@ if ($id > 0 || ! empty($ref))
print $langs->trans("WarehouseSource");
//print '';
//print '';
- print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:-1, 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200');
+ print $formproduct->selectWarehouses(! empty($object->warehouse_id)?$object->warehouse_id:'ifone', 'entrepot_id', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200');
if (count($formproduct->cache_warehouses) <= 0)
{
print ' '.$langs->trans("WarehouseSourceNotDefined").' '.$langs->trans("AddOne").'';
diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php
index 13d28189e95..c91e3a28d10 100644
--- a/htdocs/exports/export.php
+++ b/htdocs/exports/export.php
@@ -759,6 +759,7 @@ if ($step == 3 && $datatoexport)
// un formulaire en plus pour recuperer les filtres
print ' |