diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index ff3e7f3c407..476319fcdea 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -943,13 +943,13 @@ if (empty($reshook))
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
$fk_parent_line = 0;
}
-
-
-
-
+
+
+
+
if($facture_source->type == Facture::TYPE_SITUATION)
{
-
+
if(!empty($facture_source->tab_previous_situation_invoice))
{
// search the last invoice in cycle
@@ -962,40 +962,40 @@ if (empty($reshook))
$searchPreviousInvoice=false; // find, exit;
break;
}
- else
+ else
{
- $lineIndex--; // go to previous invoice in cycle
+ $lineIndex--; // go to previous invoice in cycle
}
}
-
-
+
+
$maxPrevSituationPercent = 0;
foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
{
if($prevLine->id == $line->fk_prev_id)
{
$maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent);
-
+
//$line->subprice = $line->subprice - $prevLine->subprice;
$line->total_ht = $line->total_ht - $prevLine->total_ht;
$line->total_tva = $line->total_tva - $prevLine->total_tva;
$line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
$line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
$line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
-
+
$line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
$line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
$line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
$line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
-
-
+
+
}
}
-
+
// prorata
$line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
-
-
+
+
}
}
@@ -1524,7 +1524,7 @@ if (empty($reshook))
$line->origin = $object->origin;
$line->origin_id = $line->id;
$line->fetch_optionals($line->id);
-
+
// Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée
if ($line->fk_remise_except)
{
@@ -2201,12 +2201,12 @@ if (empty($reshook))
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition
exit();
}
-
- // Outing situation invoice from cycle
+
+ // Outing situation invoice from cycle
elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $user->rights->facture->creer)
{
$object->fetch($id,'', '','', true);
-
+
if ($object->statut == Facture::STATUS_VALIDATED
&& $object->type == Facture::TYPE_SITUATION
&& $user->rights->facture->creer
@@ -2214,20 +2214,20 @@ if (empty($reshook))
&& $object->is_last_in_cycle()
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
- )
+ )
{
$outingError = 0;
$newCycle = $object->newCycle(); // we need to keep the "situation behavior" so we place it on a new situation cycle
if($newCycle > 1)
{
- // Search credit notes
+ // Search credit notes
$lastCycle = $object->situation_cycle_ref;
$lastSituationCounter = $object->situation_counter;
$linkedCreditNotesList = array();
-
+
if (count($object->tab_next_situation_invoice) > 0) {
foreach ($object->tab_next_situation_invoice as $next_invoice) {
- if($next_invoice->type == Facture::TYPE_CREDIT_NOTE
+ if($next_invoice->type == Facture::TYPE_CREDIT_NOTE
&& $next_invoice->situation_counter == $object->situation_counter
&& $next_invoice->fk_facture_source == $object->id
)
@@ -2236,7 +2236,7 @@ if (empty($reshook))
}
}
}
-
+
$object->situation_cycle_ref = $newCycle;
$object->situation_counter = 1;
$object->situation_final = 0;
@@ -2251,18 +2251,18 @@ if (empty($reshook))
$sql.= ' , situation_final=0';
$sql.= ' , situation_counter='.$object->situation_counter;
$sql.= ' WHERE rowid IN ('.implode(',',$linkedCreditNotesList).')';
-
+
$resql=$db->query($sql);
if (!$resql) $errors++;
-
+
// Change each progression persent on each lines
foreach($object->lines as $line)
{
-
+
// no traitement for special product
if ($line->product_type == 9 ) continue;
-
-
+
+
if(!empty($object->tab_previous_situation_invoice))
{
// search the last invoice in cycle
@@ -2280,8 +2280,8 @@ if (empty($reshook))
$lineIndex--; // go to previous invoice in cycle
}
}
-
-
+
+
$maxPrevSituationPercent = 0;
foreach($object->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
{
@@ -2290,19 +2290,19 @@ if (empty($reshook))
$maxPrevSituationPercent = max($maxPrevSituationPercent,$prevLine->situation_percent);
}
}
-
-
+
+
$line->situation_percent = $line->situation_percent - $maxPrevSituationPercent;
-
+
if($line->update()<0) $errors++;
-
+
}
}
}
-
+
if (!$errors)
{
- setEventMessages($langs->trans('Updated'));
+ setEventMessages($langs->trans('Updated'), '', 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
}
else
@@ -2310,7 +2310,7 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors');
}
}
- else
+ else
{
setEventMessages($langs->trans('ErrorOutingSituationInvoiceOnUpdate'), array(), 'errors');
}
@@ -2331,7 +2331,7 @@ if (empty($reshook))
$fromElement = GETPOST('fromelement');
$fromElementid = GETPOST('fromelementid');
$importLines = GETPOST('line_checkbox');
-
+
if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid))
{
if($fromElement == 'commande')
@@ -2383,27 +2383,27 @@ if (empty($reshook))
$fk_prev_id = '';
$fk_unit = $originLine->fk_unit;
$pu_ht_devise = $originLine->multicurrency_subprice;
-
+
$res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise);
-
+
if($res > 0){
$importCount++;
}else{
$error++;
}
}
- else{
- $error++;
+ else{
+ $error++;
}
}
-
+
if($error)
{
setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors');
}
}
}
-
+
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
@@ -3357,7 +3357,7 @@ else if ($id > 0 || ! empty($ref))
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1);
}
}
-
+
// Confirmation to remove invoice from cycle
if ($action == 'situationout') {
$text = $langs->trans('ConfirmRemoveSituationFromCycle', $object->ref);
@@ -3857,10 +3857,10 @@ else if ($id > 0 || ! empty($ref))
print "";
print '';
-
-
-
+
+
+
// Incoterms
if (!empty($conf->incoterm->enabled))
@@ -4022,10 +4022,10 @@ else if ($id > 0 || ! empty($ref))
// List of previous situation invoices
if (($object->situation_cycle_ref > 0) && ! empty($conf->global->INVOICE_USE_SITUATION))
{
-
+
print '
';
-
-
+
+
print '';
print '| ' . $langs->trans('ListOfSituationInvoices') . ' | ';
print ' | ';
@@ -4035,14 +4035,14 @@ else if ($id > 0 || ! empty($ref))
print '' . $langs->trans('AmountTTC') . ' | ';
print ' | ';
print '
';
-
-
+
+
$total_prev_ht = $total_prev_ttc = 0;
$total_global_ht = $total_global_ttc = 0;
-
+
if (count($object->tab_previous_situation_invoice) > 0) {
// List of previous invoices
-
+
$current_situation_counter = array();
foreach ($object->tab_previous_situation_invoice as $prev_invoice) {
$totalpaye = $prev_invoice->getSommePaiement();
@@ -4060,8 +4060,8 @@ else if ($id > 0 || ! empty($ref))
print '';
}
}
-
-
+
+
$total_global_ht += $total_prev_ht ;
$total_global_ttc += $total_prev_ttc ;
$total_global_ht += $object->total_ht;
@@ -4076,8 +4076,8 @@ else if ($id > 0 || ! empty($ref))
print '' . price($object->total_ttc) . ' | ';
print '' . $object->getLibStatut(3, $object->getSommePaiement()) . ' | ';
print '';
-
-
+
+
print '';
print '| ' . $langs->trans('CurrentSituationTotal') . ' | ';
print '';
@@ -4096,8 +4096,8 @@ else if ($id > 0 || ! empty($ref))
print ' | ' . price($total_global_ttc) . ' | ';
print ' | ';
print '
';
-
-
+
+
if (count($object->tab_next_situation_invoice) > 0) {
// List of next invoices
/*print '';
@@ -4109,14 +4109,14 @@ else if ($id > 0 || ! empty($ref))
print '| ' . $langs->trans('AmountTTC') . ' | ';
print ' | ';
print '
';*/
-
+
$total_next_ht = $total_next_ttc = 0;
-
+
foreach ($object->tab_next_situation_invoice as $next_invoice) {
$totalpaye = $next_invoice->getSommePaiement();
$total_next_ht += $next_invoice->total_ht;
$total_next_ttc += $next_invoice->total_ttc;
-
+
print '';
print '| ' . $next_invoice->getNomUrl(1) . ' | ';
print ' | ';
@@ -4126,12 +4126,12 @@ else if ($id > 0 || ! empty($ref))
print '' . price($next_invoice->total_ttc) . ' | ';
print '' . $next_invoice->getLibStatut(3, $totalpaye) . ' | ';
print '
';
-
+
}
-
+
$total_global_ht += $total_next_ht;
$total_global_ttc += $total_next_ttc;
-
+
print '';
print ' | ';
if (! empty($conf->banque->enabled)) print ' | ';
@@ -4140,7 +4140,7 @@ else if ($id > 0 || ! empty($ref))
print ' | ';
print '
';
}
-
+
print '
';
}
@@ -4712,9 +4712,9 @@ else if ($id > 0 || ! empty($ref))
print '';
} else {
print '' . $langs->trans("CreateCreditNote") . '
';
- }
+ }
}
-
+
// remove situation from cycle
if ($object->statut == Facture::STATUS_VALIDATED
&& $object->type == Facture::TYPE_SITUATION
@@ -4730,12 +4730,12 @@ else if ($id > 0 || ! empty($ref))
{
print '';
}
- else
+ else
{
print '';
}
}
-
+
// Create next situation invoice
if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) {
if ($object->is_last_in_cycle() && $object->situation_final != 1) {
@@ -4804,16 +4804,16 @@ else if ($id > 0 || ! empty($ref))
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
-
+
$compatibleImportElementsList = false;
- if($user->rights->facture->creer
- && $object->statut == Facture::STATUS_DRAFT
+ if($user->rights->facture->creer
+ && $object->statut == Facture::STATUS_DRAFT
&& ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) )
{
$compatibleImportElementsList = array('commande','propal'); // import from linked elements
}
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem,$compatibleImportElementsList);
-
+
// Show online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
index 8178af40c37..a7268ee0ea3 100644
--- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
+++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
@@ -364,7 +364,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$array_other=$this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in order as contact_xxx tags
$array_thirdparty_contact = array();
- if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
+ if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
index 98b644c8cce..99eb9feb2ea 100644
--- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
+++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
@@ -304,7 +304,7 @@ class doc_generic_contract_odt extends ModelePDFContract
$array_other=$this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in contract as contact_xxx tags
$array_thirdparty_contact = array();
- if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
+ if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
$substitutionarray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
index 6d9d5172a7f..79741886119 100644
--- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -372,7 +372,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$array_other=$this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in invoice as contact_xxx tags
$array_thirdparty_contact = array();
- if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
+ if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
index 6c5fa8652f9..f63d62149eb 100644
--- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
+++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php
@@ -381,7 +381,7 @@ class doc_generic_product_odt extends ModelePDFProduct
$array_other=$this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in product as contact_xxx tags
$array_thirdparty_contact = array();
- if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
+ if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
index 5c0d025252e..35cbed4acf4 100644
--- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
+++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
@@ -579,7 +579,7 @@ class doc_generic_project_odt extends ModelePDFProjects
$array_other=$this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in project as contact_xxx tags
$array_project_contact = array();
- if ($usecontact) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
+ if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
index 0b71e9e862f..589d2d006c2 100644
--- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
+++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
@@ -395,7 +395,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$array_other=$this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in proposal as contact_xxx tags
$array_thirdparty_contact = array();
- if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
+ if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);
diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
index 0cadf3362d4..d7ceffaaf72 100644
--- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
+++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
@@ -381,7 +381,7 @@ class doc_generic_stock_odt extends ModelePDFStock
$array_other=$this->get_substitutionarray_other($outputlangs);
// retrieve contact information for use in stock as contact_xxx tags
$array_thirdparty_contact = array();
- if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
+ if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
complete_substitutions_array($tmparray, $outputlangs, $object);