diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php
index f565169b111..ce327cc5187 100644
--- a/htdocs/admin/facture_situation.php
+++ b/htdocs/admin/facture_situation.php
@@ -36,13 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
-if (!$user->admin) accessforbidden();
+if (! $user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
-$type = 'invoice';
+$type='invoice';
/*
@@ -57,17 +57,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
* View
*/
-$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
+$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
llxHeader(
"", $langs->trans("BillsSetup"),
'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
);
-$form = new Form($db);
+$form=new Form($db);
-$linkback = ''.$langs->trans("BackToModuleList").'';
+$linkback=''.$langs->trans("BackToModuleList").'';
print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
$head = invoice_admin_prepare_head();
@@ -96,7 +96,26 @@ print "\n";
_printOnOff('INVOICE_USE_SITUATION', $langs->trans('UseSituationInvoices'));
_printOnOff('INVOICE_USE_SITUATION_CREDIT_NOTE', $langs->trans('UseSituationInvoicesCreditNote'));
-_printOnOff('INVOICE_USE_SITUATION_RETAINED_WARRANTY', $langs->trans('Retainedwarranty'));
+//_printOnOff('INVOICE_USE_RETAINED_WARRANTY', $langs->trans('Retainedwarranty'));
+
+$confkey = 'INVOICE_USE_RETAINED_WARRANTY';
+
+$arrayAvailableType = array(
+ Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
+ Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
+);
+$selected = array();
+$implodeglue = '+';
+if(!empty($conf->global->{$confkey}) && !is_array($conf->global->{$confkey})){
+ $selected = explode('+', $conf->global->{$confkey});
+}
+
+$curentInput = (empty($inputCount)?1:($inputCount+1));
+$formSelectInvoiceType = $form->selectarray('value'. $curentInput, $arrayAvailableType, $selected, 1);
+_printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty'), '', array(), $formSelectInvoiceType);
+
+//_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituation'));
+_printOnOff('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION', $langs->trans('RetainedwarrantyOnlyForSituationFinal'));
$metas = array(
'type' => 'number',
@@ -107,7 +126,7 @@ $metas = array(
_printInputFormPart('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT', $langs->trans('RetainedwarrantyDefaultPercent'), '', $metas);
// Conditions paiements
-$inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
+$inputCount = empty($inputCount)?1:($inputCount+1);
print '
';
print '| ';
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index f1a20e5b8dc..b6f9c4d7969 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -302,9 +302,9 @@ class Facture extends CommonInvoice
'situation_cycle_ref' =>array('type'=>'smallint(6)', 'label'=>'Situation cycle ref', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>230),
'situation_counter' =>array('type'=>'smallint(6)', 'label'=>'Situation counter', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION', 'visible'=>-1, 'position'=>235),
'situation_final' =>array('type'=>'smallint(6)', 'label'=>'Situation final', 'enabled'=>'empty($conf->global->INVOICE_USE_SITUATION) ? 0 : 1', 'visible'=>-1, 'position'=>240),
- 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>245),
- 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>250),
- 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>'$conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>255),
+ 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>245),
+ 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>250),
+ 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>255),
'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>260),
'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermLabel', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>265),
'date_pointoftax' =>array('type'=>'date', 'label'=>'DatePointOfTax', 'enabled'=>'$conf->global->INVOICE_POINTOFTAX_DATE', 'visible'=>-1, 'position'=>270),
@@ -813,12 +813,12 @@ class Facture extends CommonInvoice
$vatrate = $line->tva_tx;
if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')';
- if (!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
- $originid = $line->origin_id;
- $origintype = $line->origin;
+ if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
+ $originid=$line->origin_id;
+ $origintype=$line->origin;
} else {
- $originid = $line->id;
- $origintype = $this->element;
+ $originid=$line->id;
+ $origintype=$this->element;
}
$result = $this->addline(
@@ -3733,44 +3733,44 @@ class Facture extends CommonInvoice
}
if (!empty($addon)) {
- dol_syslog("Call getNextNumRef with ".$addonConstName." = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG);
+ dol_syslog("Call getNextNumRef with " . $addonConstName . " = " . $conf->global->FACTURE_ADDON . ", thirdparty=" . $soc->nom . ", type=" . $soc->typent_code, LOG_DEBUG);
$mybool = false;
- $file = $addon.'.php';
+ $file = $addon . '.php';
$classname = $addon;
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
- $dir = dol_buildpath($reldir.'core/modules/'.$moduleName.'/');
+ $dir = dol_buildpath($reldir . 'core/modules/' . $moduleName . '/');
// Load file with numbering class (if found)
- if (is_file($dir.$file) && is_readable($dir.$file)) {
- $mybool |= include_once $dir.$file;
+ if (is_file($dir . $file) && is_readable($dir . $file)) {
+ $mybool |= include_once $dir . $file;
}
}
// For compatibility
if (!$mybool) {
- $file = $addon.'/'.$addon.'.modules.php';
- $classname = 'mod_'.$moduleName.'_'.$addon;
+ $file = $addon . '/' . $addon . '.modules.php';
+ $classname = 'mod_' . $moduleName . '_' . $addon;
$classname = preg_replace('/\-.*$/', '', $classname);
// Include file with class
foreach ($conf->file->dol_document_root as $dirroot) {
- $dir = $dirroot.'/core/modules/'.$moduleName.'/';
+ $dir = $dirroot . '/core/modules/' . $moduleName . '/';
// Load file with numbering class (if found)
- if (is_file($dir.$file) && is_readable($dir.$file)) {
- $mybool |= include_once $dir.$file;
+ if (is_file($dir . $file) && is_readable($dir . $file)) {
+ $mybool |= include_once $dir . $file;
}
}
}
if (!$mybool) {
- dol_print_error('', 'Failed to include file '.$file);
+ dol_print_error('', 'Failed to include file ' . $file);
return '';
}
@@ -3789,7 +3789,7 @@ class Facture extends CommonInvoice
return $numref;
} else {
$langs->load('errors');
- print $langs->trans('Error').' '.$langs->trans('ErrorModuleSetupNotComplete', $langs->transnoentitiesnoconv($moduleSourceName));
+ print $langs->trans('Error') . ' ' . $langs->trans('ErrorModuleSetupNotComplete', $langs->transnoentitiesnoconv($moduleSourceName));
return '';
}
}
@@ -4742,6 +4742,43 @@ class Facture extends CommonInvoice
return $hasDelay;
}
+ /**
+ * Currently used for documents generation : to know if retained warranty need to be displayed
+ * @return bool
+ */
+ public function displayRetainedWarranty()
+ {
+ global $conf;
+
+ // TODO : add a flag on invoices to store this conf : INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION
+
+ // note : we dont need to test INVOICE_USE_RETAINED_WARRANTY because if $this->retained_warranty is not empty it's because it was set when this conf was active
+
+ $displayWarranty = false;
+ if(!empty($this->retained_warranty)) {
+ $displayWarranty = true;
+
+ if ($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION)) {
+ // Check if this situation invoice is 100% for real
+ $displayWarranty = false;
+ if (!empty($this->situation_final)) {
+ $displayWarranty = true;
+ } elseif (!empty($this->lines) && $this->status == Facture::STATUS_DRAFT) {
+ // $object->situation_final need validation to be done so this test is need for draft
+ $displayWarranty = true;
+
+ foreach ($this->lines as $i => $line) {
+ if ($line->product_type < 2 && $line->situation_percent < 100) {
+ $displayWarranty = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return $displayWarranty;
+ }
/**
* @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT)
@@ -4757,7 +4794,7 @@ class Facture extends CommonInvoice
$retainedWarrantyAmount = 0;
// Billed - retained warranty
- if ($this->type == Facture::TYPE_SITUATION)
+ if($this->type == Facture::TYPE_SITUATION && !empty($conf->global->INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION))
{
$displayWarranty = true;
// Check if this situation invoice is 100% for real
@@ -4795,7 +4832,10 @@ class Facture extends CommonInvoice
if ($rounding < 0) {
$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
- return round($retainedWarrantyAmount, 2);
+ }
+
+ if($rounding>0){
+ return round($retainedWarrantyAmount, $rounding);
}
return $retainedWarrantyAmount;
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 1b0c99c3bfb..17f70cab375 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -208,7 +208,7 @@ $arrayfields = array(
'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
);
-if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
+if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY)
{
$arrayfields['f.retained_warranty'] = array('label'=>$langs->trans("RetainedWarranty"), 'checked'=>0, 'position'=>86);
}
@@ -1137,7 +1137,7 @@ if ($resql)
$facturestatic->note_public = $obj->note_public;
$facturestatic->note_private = $obj->note_private;
- if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_SITUATION_RETAINED_WARRANTY)
+ if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY)
{
$facturestatic->retained_warranty = $obj->retained_warranty;
$facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index b482feeef94..cc26c4ba13b 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1393,47 +1393,33 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
// Retained warranty
- if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty))))
+ if ($object->displayRetainedWarranty())
{
- $displayWarranty = false;
+ $pdf->SetTextColor(40, 40, 40);
+ $pdf->SetFillColor(255, 255, 255);
- // Check if this situation invoice is 100% for real
- if (!empty($object->lines)) {
- $displayWarranty = true;
- foreach ($object->lines as $i => $line) {
- if ($line->product_type < 2 && $line->situation_percent < 100) {
- $displayWarranty = false;
- break;
- }
- }
- }
+ $retainedWarranty = $object->getRetainedWarrantyAmount();
+ $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
- if ($displayWarranty) {
- $pdf->SetTextColor(40, 40, 40);
- $pdf->SetFillColor(255, 255, 255);
+ // Billed - retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
- $retainedWarranty = $object->total_ttc * $object->retained_warranty / 100;
- $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
- // Billed - retained warranty
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
+ // retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
+ $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)';
+ $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
- // retained warranty
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
- $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)';
- $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
-
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
- }
}
}
}
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index 1c2e1277ce8..6fad6fc4665 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -43,82 +43,82 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/
class pdf_sponge extends ModelePDFFactures
{
- /**
- * @var DoliDb Database handler
- */
- public $db;
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
/**
- * @var string model name
- */
- public $name;
+ * @var string model name
+ */
+ public $name;
/**
- * @var string model description (short text)
- */
- public $description;
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
/**
- * @var int Save the name of generated file as the main doc when generating a doc with this template
- */
- public $update_main_doc_field;
+ * @var string document type
+ */
+ public $type;
/**
- * @var string document type
- */
- public $type;
-
- /**
- * @var array Minimum version of PHP required by module.
- * e.g.: PHP ≥ 5.5 = array(5, 5)
- */
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
public $phpmin = array(5, 5);
/**
- * Dolibarr version of the loaded document
- * @var string
- */
+ * Dolibarr version of the loaded document
+ * @var string
+ */
public $version = 'dolibarr';
- /**
- * @var int page_largeur
- */
- public $page_largeur;
+ /**
+ * @var int page_largeur
+ */
+ public $page_largeur;
/**
- * @var int page_hauteur
- */
- public $page_hauteur;
+ * @var int page_hauteur
+ */
+ public $page_hauteur;
/**
- * @var array format
- */
- public $format;
+ * @var array format
+ */
+ public $format;
/**
- * @var int marge_gauche
- */
+ * @var int marge_gauche
+ */
public $marge_gauche;
/**
- * @var int marge_droite
- */
+ * @var int marge_droite
+ */
public $marge_droite;
/**
- * @var int marge_haute
- */
+ * @var int marge_haute
+ */
public $marge_haute;
/**
- * @var int marge_basse
- */
+ * @var int marge_basse
+ */
public $marge_basse;
- /**
- * Issuer
- * @var Societe Object that emits
- */
+ /**
+ * Issuer
+ * @var Societe Object that emits
+ */
public $emetteur;
/**
@@ -776,9 +776,9 @@ class pdf_sponge extends ModelePDFFactures
$parameters = array(
'object' => $object,
'i' => $i,
- 'pdf' => &$pdf,
- 'curY' => &$curY,
- 'nexY' => &$nexY,
+ 'pdf' =>& $pdf,
+ 'curY' =>& $curY,
+ 'nexY' =>& $nexY,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails
);
@@ -1204,13 +1204,13 @@ class pdf_sponge extends ModelePDFFactures
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
$posy = $pdf->GetY() + 2;
- }
+ }
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
{
@@ -1219,13 +1219,13 @@ class pdf_sponge extends ModelePDFFactures
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
$posy = $pdf->GetY() + 2;
- }
+ }
}
}
}
@@ -1267,10 +1267,10 @@ class pdf_sponge extends ModelePDFFactures
{
global $conf, $mysoc, $hookmanager;
- $sign = 1;
- if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy;
$tab2_hl = 4;
@@ -1311,10 +1311,10 @@ class pdf_sponge extends ModelePDFFactures
}
if (!empty($i)) {
- $avancementGlobal = $percent / $i;
+ $avancementGlobal = $percent / $i;
}
else {
- $avancementGlobal = 0;
+ $avancementGlobal = 0;
}
$object->fetchPreviousNextSituationInvoice();
@@ -1323,98 +1323,98 @@ class pdf_sponge extends ModelePDFFactures
$total_a_payer = 0;
$total_a_payer_ttc = 0;
foreach ($TPreviousIncoice as &$fac) {
- $total_a_payer += $fac->total_ht;
- $total_a_payer_ttc += $fac->total_ttc;
+ $total_a_payer += $fac->total_ht;
+ $total_a_payer_ttc += $fac->total_ttc;
}
$total_a_payer += $object->total_ht;
$total_a_payer_ttc += $object->total_ttc;
if (!empty($avancementGlobal)) {
- $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
- $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
+ $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
+ $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
}
else {
- $total_a_payer = 0;
- $total_a_payer_ttc = 0;
+ $total_a_payer = 0;
+ $total_a_payer_ttc = 0;
}
$i = 1;
if (!empty($TPreviousIncoice)) {
- $pdf->setY($tab2_top);
- $posy = $pdf->GetY();
+ $pdf->setY($tab2_top);
+ $posy = $pdf->GetY();
- foreach ($TPreviousIncoice as &$fac) {
- if ($posy > $this->page_hauteur - 4) {
- $this->_pagefoot($pdf, $object, $outputlangs, 1);
- $pdf->addPage();
- $pdf->setY($this->marge_haute);
- $posy = $pdf->GetY();
- }
+ foreach ($TPreviousIncoice as &$fac) {
+ if ($posy > $this->page_hauteur - 4) {
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
- // cumul TVA précédent
- $index++;
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ // cumul TVA précédent
+ $index++;
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $pdf->SetXY($col2x, $posy);
+ $pdf->SetXY($col2x, $posy);
- $facSign = '';
- if ($i > 1) {
- $facSign = $fac->total_ht >= 0 ? '+' : '';
- }
+ $facSign = '';
+ if ($i > 1) {
+ $facSign = $fac->total_ht >= 0 ? '+' : '';
+ }
- $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
+ $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
- $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
- $i++;
- $posy += $tab2_hl;
+ $i++;
+ $posy += $tab2_hl;
- $pdf->setY($posy);
- }
+ $pdf->setY($posy);
+ }
- // Display current total
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ // Display current total
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $pdf->SetXY($col2x, $posy);
- $facSign = '';
- if ($i > 1) {
- $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
- }
+ $pdf->SetXY($col2x, $posy);
+ $facSign = '';
+ if ($i > 1) {
+ $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
+ }
- if ($fac->type === facture::TYPE_CREDIT_NOTE) {
- $facSign = '-'; // les avoirs
- }
+ if ($fac->type === facture::TYPE_CREDIT_NOTE) {
+ $facSign = '-'; // les avoirs
+ }
- $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
- $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+ $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
- $posy += $tab2_hl;
+ $posy += $tab2_hl;
- // Display all total
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
+ // Display all total
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
- $pdf->SetXY($col2x, $posy);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
- $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($col2x, $posy);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetFont('', '', $default_font_size - 2);
- $posy += $tab2_hl;
+ $posy += $tab2_hl;
- if ($posy > $this->page_hauteur - 4) {
- $pdf->addPage();
- $pdf->setY($this->marge_haute);
- $posy = $pdf->GetY();
- }
+ if ($posy > $this->page_hauteur - 4) {
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
- $tab2_top = $posy;
- $index = 0;
+ $tab2_top = $posy;
+ $index = 0;
}
$tab2_top += 3;
@@ -1425,30 +1425,30 @@ class pdf_sponge extends ModelePDFFactures
// Total remise
$total_line_remise = 0;
foreach ($object->lines as $i => $line) {
- $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
- // Gestion remise sous forme de ligne négative
- if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
+ $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
+ // Gestion remise sous forme de ligne négative
+ if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
}
if ($total_line_remise > 0) {
- if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
- $index++;
- }
- // Show total NET before discount
- if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
+ $index++;
+ }
+ // Show total NET before discount
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
- $index++;
- }
+ $index++;
+ }
}
// Total HT
@@ -1475,7 +1475,7 @@ class pdf_sponge extends ModelePDFFactures
}
else
{
- // FIXME amount of vat not supported with multicurrency
+ // FIXME amount of vat not supported with multicurrency
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1510,7 +1510,7 @@ class pdf_sponge extends ModelePDFFactures
}
}
}
- //}
+ //}
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1543,7 +1543,7 @@ class pdf_sponge extends ModelePDFFactures
}
}
}
- //}
+ //}
// VAT
// Situations totals migth be wrong on huge amounts
@@ -1554,13 +1554,13 @@ class pdf_sponge extends ModelePDFFactures
}
if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
- if (!empty($sum_pdf_tva))
- {
+ if (!empty($sum_pdf_tva))
+ {
$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
- }
- else {
- $coef_fix_tva = 1;
- }
+ }
+ else {
+ $coef_fix_tva = 1;
+ }
foreach ($this->tva as $tvakey => $tvaval) {
@@ -1626,7 +1626,7 @@ class pdf_sponge extends ModelePDFFactures
}
}
}
- //}
+ //}
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
@@ -1636,7 +1636,7 @@ class pdf_sponge extends ModelePDFFactures
foreach ($localtax_rate as $tvakey => $tvaval)
{
- // retrieve global local tax
+ // retrieve global local tax
if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
@@ -1685,66 +1685,35 @@ class pdf_sponge extends ModelePDFFactures
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
- /*if($object->type == Facture::TYPE_SITUATION)
- {
- // reste à payer total
- $index++;
-
- $pdf->SetFont('','', $default_font_size - 1);
- $pdf->SetFillColor(255,255,255);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities('SituationTotalRayToRest'), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer_ttc-$deja_regle, 0, $outputlangs), 0, 'R', 1);
- }*/
// Retained warranty
- if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty))))
+ if ($object->displayRetainedWarranty())
{
- $displayWarranty = false;
+ $pdf->SetTextColor(40, 40, 40);
+ $pdf->SetFillColor(255, 255, 255);
- // Check if this situation invoice is 100% for real
- if (!empty($object->situation_final)) {
- $displayWarranty = true;
- }
- elseif (!empty($object->lines) && $object->status == Facture::STATUS_DRAFT) {
- // $object->situation_final need validation to be done so this test is need for draft
- $displayWarranty = true;
- foreach ($object->lines as $i => $line) {
- if ($line->product_type < 2 && $line->situation_percent < 100) {
- $displayWarranty = false;
- break;
- }
- }
- }
+ $retainedWarranty = $object->getRetainedWarrantyAmount();
+ $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
- if ($displayWarranty) {
- $pdf->SetTextColor(40, 40, 40);
- $pdf->SetFillColor(255, 255, 255);
+ // Billed - retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("ToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
- $retainedWarranty = $total_a_payer_ttc * $object->retained_warranty / 100;
- $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
- // Billed - retained warranty
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
+ // retained warranty
+ $index++;
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
+ $retainedWarrantyToPayOn = $outputlangs->transnoentities("RetainedWarranty").' ('.$object->retained_warranty.'%)';
+ $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("toPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
- // retained warranty
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-
- $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)';
- $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
-
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
- }
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
}
}
}
@@ -1878,7 +1847,7 @@ class pdf_sponge extends ModelePDFFactures
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
if (empty($hidetop)) {
- $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
}
}
@@ -1906,9 +1875,9 @@ class pdf_sponge extends ModelePDFFactures
// Show Draft Watermark
if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
- {
- pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
- }
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
+ }
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
@@ -1916,7 +1885,7 @@ class pdf_sponge extends ModelePDFFactures
$w = 110;
$posy = $this->marge_haute;
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - $w;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1936,7 +1905,7 @@ class pdf_sponge extends ModelePDFFactures
}
if (is_readable($logo))
{
- $height = pdf_getHeightForLogo($logo);
+ $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
@@ -2088,16 +2057,16 @@ class pdf_sponge extends ModelePDFFactures
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
- $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
- if (count($arrayidcontact) > 0)
- {
- $usertmp = new User($this->db);
- $usertmp->fetch($arrayidcontact[0]);
- $posy += 4;
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
- }
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0)
+ {
+ $usertmp = new User($this->db);
+ $usertmp->fetch($arrayidcontact[0]);
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
}
$posy += 1;
@@ -2203,7 +2172,7 @@ class pdf_sponge extends ModelePDFFactures
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
+ *
* @param PDF $pdf PDF
* @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
@@ -2222,28 +2191,28 @@ class pdf_sponge extends ModelePDFFactures
*
* @param object $object common object
* @param Translate $outputlangs langs
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return null
- */
- public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
- {
- global $conf, $hookmanager;
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return null
+ */
+ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ global $conf, $hookmanager;
- // Default field style for content
- $this->defaultContentsFieldsStyle = array(
- 'align' => 'R', // R,C,L
- 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
+ // Default field style for content
+ $this->defaultContentsFieldsStyle = array(
+ 'align' => 'R', // R,C,L
+ 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
- // Default field style for content
- $this->defaultTitlesFieldsStyle = array(
- 'align' => 'C', // R,C,L
- 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
+ // Default field style for content
+ $this->defaultTitlesFieldsStyle = array(
+ 'align' => 'C', // R,C,L
+ 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
- /*
+ /*
* For exemple
$this->cols['theColKey'] = array(
'rank' => $rank, // int : use for ordering columns
@@ -2261,165 +2230,165 @@ class pdf_sponge extends ModelePDFFactures
);
*/
- $rank = 0; // do not use negative rank
- $this->cols['desc'] = array(
- 'rank' => $rank,
- 'width' => false, // only for desc
- 'status' => true,
- 'title' => array(
- 'textkey' => 'Designation', // use lang key is usefull in somme case with module
- 'align' => 'L',
- // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
- // 'label' => ' ', // the final label
- 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- 'content' => array(
- 'align' => 'L',
- 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- );
+ $rank = 0; // do not use negative rank
+ $this->cols['desc'] = array(
+ 'rank' => $rank,
+ 'width' => false, // only for desc
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Designation', // use lang key is usefull in somme case with module
+ 'align' => 'L',
+ // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+ // 'label' => ' ', // the final label
+ 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'content' => array(
+ 'align' => 'L',
+ 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ );
- // PHOTO
- $rank = $rank + 10;
- $this->cols['photo'] = array(
- 'rank' => $rank,
- 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Photo',
- 'label' => ' '
- ),
- 'content' => array(
- 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- 'border-left' => false, // remove left line separator
- );
+ // PHOTO
+ $rank = $rank + 10;
+ $this->cols['photo'] = array(
+ 'rank' => $rank,
+ 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Photo',
+ 'label' => ' '
+ ),
+ 'content' => array(
+ 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'border-left' => false, // remove left line separator
+ );
- if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
- {
- $this->cols['photo']['status'] = true;
- }
+ if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
+ {
+ $this->cols['photo']['status'] = true;
+ }
- $rank = $rank + 10;
- $this->cols['vat'] = array(
- 'rank' => $rank,
- 'status' => false,
- 'width' => 16, // in mm
- 'title' => array(
- 'textkey' => 'VAT'
- ),
- 'border-left' => true, // add left line separator
- );
+ $rank = $rank + 10;
+ $this->cols['vat'] = array(
+ 'rank' => $rank,
+ 'status' => false,
+ 'width' => 16, // in mm
+ 'title' => array(
+ 'textkey' => 'VAT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
- if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
- {
- $this->cols['vat']['status'] = true;
- }
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
+ {
+ $this->cols['vat']['status'] = true;
+ }
- $rank = $rank + 10;
- $this->cols['subprice'] = array(
- 'rank' => $rank,
- 'width' => 19, // in mm
- 'status' => true,
- 'title' => array(
- 'textkey' => 'PriceUHT'
- ),
- 'border-left' => true, // add left line separator
- );
+ $rank = $rank + 10;
+ $this->cols['subprice'] = array(
+ 'rank' => $rank,
+ 'width' => 19, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'PriceUHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
- $rank = $rank + 10;
- $this->cols['qty'] = array(
- 'rank' => $rank,
- 'width' => 16, // in mm
- 'status' => true,
- 'title' => array(
- 'textkey' => 'Qty'
- ),
- 'border-left' => true, // add left line separator
- );
+ $rank = $rank + 10;
+ $this->cols['qty'] = array(
+ 'rank' => $rank,
+ 'width' => 16, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Qty'
+ ),
+ 'border-left' => true, // add left line separator
+ );
- $rank = $rank + 10;
- $this->cols['progress'] = array(
- 'rank' => $rank,
- 'width' => 19, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Progress'
- ),
- 'border-left' => true, // add left line separator
- );
+ $rank = $rank + 10;
+ $this->cols['progress'] = array(
+ 'rank' => $rank,
+ 'width' => 19, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Progress'
+ ),
+ 'border-left' => true, // add left line separator
+ );
- if ($this->situationinvoice)
- {
- $this->cols['progress']['status'] = true;
- }
+ if ($this->situationinvoice)
+ {
+ $this->cols['progress']['status'] = true;
+ }
- $rank = $rank + 10;
- $this->cols['unit'] = array(
- 'rank' => $rank,
- 'width' => 11, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Unit'
- ),
- 'border-left' => true, // add left line separator
- );
- if ($conf->global->PRODUCT_USE_UNITS) {
- $this->cols['unit']['status'] = true;
- }
+ $rank = $rank + 10;
+ $this->cols['unit'] = array(
+ 'rank' => $rank,
+ 'width' => 11, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Unit'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if ($conf->global->PRODUCT_USE_UNITS) {
+ $this->cols['unit']['status'] = true;
+ }
- $rank = $rank + 10;
- $this->cols['discount'] = array(
- 'rank' => $rank,
- 'width' => 13, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'ReductionShort'
- ),
- 'border-left' => true, // add left line separator
- );
- if ($this->atleastonediscount) {
- $this->cols['discount']['status'] = true;
- }
+ $rank = $rank + 10;
+ $this->cols['discount'] = array(
+ 'rank' => $rank,
+ 'width' => 13, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'ReductionShort'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if ($this->atleastonediscount) {
+ $this->cols['discount']['status'] = true;
+ }
- $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
- $this->cols['totalexcltax'] = array(
- 'rank' => $rank,
- 'width' => 26, // in mm
- 'status' => true,
- 'title' => array(
- 'textkey' => 'TotalHT'
- ),
- 'border-left' => true, // add left line separator
- );
+ $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
+ $this->cols['totalexcltax'] = array(
+ 'rank' => $rank,
+ 'width' => 26, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'TotalHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
- // Add extrafields cols
- if (!empty($object->lines)) {
- $line = reset($object->lines);
- $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
- }
+ // Add extrafields cols
+ if (!empty($object->lines)) {
+ $line = reset($object->lines);
+ $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
+ }
- $parameters = array(
- 'object' => $object,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails,
- 'hidedesc' => $hidedesc,
- 'hideref' => $hideref
- );
+ $parameters = array(
+ 'object' => $object,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails,
+ 'hidedesc' => $hidedesc,
+ 'hideref' => $hideref
+ );
- $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
- if ($reshook < 0)
- {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
- elseif (empty($reshook))
- {
- $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
- }
- else
- {
- $this->cols = $hookmanager->resArray;
- }
+ $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
+ if ($reshook < 0)
+ {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ }
+ elseif (empty($reshook))
+ {
+ $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
+ }
+ else
+ {
+ $this->cols = $hookmanager->resArray;
+ }
}
}
diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
index 8603f612c3d..628b298329d 100644
--- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
+++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
@@ -200,6 +200,8 @@ DELETE FROM llx_const WHERE name = __ENCRYPT('DONATION_ART885')__;
ALTER TABLE llx_extrafields MODIFY COLUMN printable integer DEFAULT 0;
ALTER TABLE llx_extrafields ADD COLUMN printable integer DEFAULT 0;
+UPDATE llx_const SET name = 'INVOICE_USE_RETAINED_WARRANTY' WHERE name = 'INVOICE_USE_SITUATION_RETAINED_WARRANTY';
+
ALTER TABLE llx_accounting_account DROP COLUMN pcg_subtype;
ALTER TABLE llx_product ADD COLUMN accountancy_code_buy_intra varchar(32) AFTER accountancy_code_buy;
diff --git a/htdocs/install/mysql/tables/llx_commandedet.key.sql b/htdocs/install/mysql/tables/llx_commandedet.key.sql
index bba65d62aa0..a609294a363 100644
--- a/htdocs/install/mysql/tables/llx_commandedet.key.sql
+++ b/htdocs/install/mysql/tables/llx_commandedet.key.sql
@@ -25,3 +25,8 @@ ALTER TABLE llx_commandedet ADD INDEX idx_commandedet_fk_product (fk_product);
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_commande FOREIGN KEY (fk_commande) REFERENCES llx_commande (rowid);
+ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_commandefourndet FOREIGN KEY (fk_commandefourndet) REFERENCES llx_commande_fournisseurdet (rowid);
+--ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_multicurrency FOREIGN KEY (fk_multicurrency) REFERENCES llx_multicurrency (rowid);
+--ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_product_fournisseur_price FOREIGN KEY (fk_product_fournisseur_price) REFERENCES llx_product_fournisseur_price (rowid);
+--ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_remise_except FOREIGN KEY (fk_remise_except) REFERENCES llx_societe_remise_except (rowid);
+
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 1293a51c193..ab26114d905 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -219,7 +219,10 @@ ShowInvoiceSituation=Show situation invoice
UseSituationInvoices=Allow situation invoice
UseSituationInvoicesCreditNote=Allow situation invoice credit note
Retainedwarranty=Retained warranty
+AllowedInvoiceForRetainedWarranty=Retained warranty usable on the following types of invoices
RetainedwarrantyDefaultPercent=Retained warranty default percent
+RetainedwarrantyOnlyForSituation=Make "retained warranty" available only for situation invoices
+RetainedwarrantyOnlyForSituationFinal=On situation invoices the global "retained warranty" deduction is applied only on the final situation
ToPayOn=To pay on %s
toPayOn=to pay on %s
RetainedWarranty=Retained Warranty
|
|