From 53979ad58cbcc905481366579026933ac097ffc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Sep 2013 14:29:09 +0200 Subject: [PATCH 1/3] Fix: Bad param --- htdocs/compta/bank/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 407a5398dc5..62ef1957f45 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -71,7 +71,7 @@ if ($_POST["action"] == 'add') $account->currency_code = trim($_POST["account_currency_code"]); - $account->state_id = $_POST["account_departement_id"]; + $account->state_id = $_POST["account_state_id"]; $account->country_id = $_POST["account_country_id"]; $account->min_allowed = $_POST["account_min_allowed"]; From b74f73c8853053e2dbfe34a44485481c5d9fa5ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Sep 2013 10:53:46 +0200 Subject: [PATCH 2/3] Fix: Calculation of deposit amount when using a percent was done only on last line. --- htdocs/compta/facture.php | 94 +++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index bd058a9418e..02a60d4764a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1,28 +1,28 @@ * Copyright (C) 2004 Eric Seigne -* Copyright (C) 2004-2013 Laurent Destailleur -* Copyright (C) 2005 Marc Barilley / Ocebo -* Copyright (C) 2005-2012 Regis Houssin -* Copyright (C) 2006 Andre Cianfarani -* Copyright (C) 2010-2013 Juanjo Menent -* Copyright (C) 2012 Christophe Battarel -* Copyright (C) 2013 Jean-Francois FERRY -* Copyright (C) 2013 Florian Henry -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2013 Jean-Francois FERRY + * Copyright (C) 2013 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /** * \file htdocs/compta/facture.php @@ -100,7 +100,7 @@ $hookmanager->initHooks(array('invoicecard')); /* * Actions -*/ + */ $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -872,14 +872,18 @@ else if ($action == 'add' && $user->rights->facture->creer) if ($id > 0) { - //If deposit invoice - if ($_POST['type'] == 3) { + // If deposit invoice + if ($_POST['type'] == 3) + { $typeamount=GETPOST('typedeposit','alpha'); $valuedeposit=GETPOST('valuedeposit','int'); - if ($typeamount=='amount') { + if ($typeamount=='amount') + { $amountdeposit=$valuedeposit; - }else { + } + else + { $amountdeposit=0; dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); @@ -887,19 +891,20 @@ else if ($action == 'add' && $user->rights->facture->creer) $classname = ucfirst($subelement); $srcobject = new $classname($db); - dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add deposit line"); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add deposit lines"); $result=$srcobject->fetch($object->origin_id); if ($result > 0) { $totalamount=0; $lines = $srcobject->lines; - $num=count($lines); - for ($i=0;$i<$num;$i++) + $numlines=count($lines); + for ($i=0; $i<$numlines; $i++) { - $totalamount=+$lines[$i]->subprice; + $totalamount += $lines[$i]->subprice; } - if ($totalamount!=0) { + if ($totalamount!=0) + { $amountdeposit=($totalamount*$valuedeposit)/100; } } @@ -1537,7 +1542,7 @@ else if ($action == 'down' && $user->rights->facture->creer) /* * Add file in email form -*/ + */ if (GETPOST('addfile')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1552,7 +1557,7 @@ if (GETPOST('addfile')) /* * Remove file in email form -*/ + */ if (! empty($_POST['removedfile'])) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1568,7 +1573,7 @@ if (! empty($_POST['removedfile'])) /* * Send mail -*/ + */ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) { $langs->load('mails'); @@ -1742,7 +1747,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO /* * Generate document -*/ + */ else if ($action == 'builddoc') // En get ou en post { $object->fetch($id); @@ -2000,8 +2005,7 @@ if ($action == 'create') // Ref print ''.$langs->trans('Ref').''.$langs->trans('Draft').''; - // Tiers - print ''; + // Thirdparty print ''.$langs->trans('Customer').''; if($soc->id > 0) { @@ -2018,7 +2022,7 @@ if ($action == 'create') } print ''."\n"; - // Factures predefinies + // Predefined invoices if (empty($origin) && empty($originid) && $socid > 0) { $sql = 'SELECT r.rowid, r.titre, r.total_ttc'; @@ -2125,10 +2129,13 @@ if ($action == 'create') print ''; $desc=$form->textwithpicto($langs->trans("InvoiceDeposit"),$langs->transnoentities("InvoiceDepositDesc"),1); print ''; - if (($origin=='propal') ) { - print ''; - print ''; + print '
'.$desc.''.$langs->trans('Value').':'; + if (($origin=='propal')) + { + print ''; + $arraylist=array('amount'=>'FixAmount','variable'=>'VarAmount'); + print $form->selectarray('typedeposit',$arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); + print ''.$langs->trans('Value').':'; } print '
'; print ''."\n"; @@ -2395,6 +2402,7 @@ if ($action == 'create') print ''; } + print '
'; } else if ($id > 0 || ! empty($ref)) { From ad09470f48dbbf8374171c82847145e916c7c79e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Sep 2013 19:53:27 +0200 Subject: [PATCH 3/3] Fix: Better management of pdf generation when tcpdf not available. --- htdocs/core/modules/action/rapport.pdf.php | 2 +- .../modules/cheque/pdf/pdf_blochet.class.php | 2 +- .../commande/doc/pdf_einstein.modules.php | 2 +- .../doc/pdf_expedition_merou.modules.php | 4 +- .../doc/pdf_expedition_rouget.modules.php | 4 +- .../modules/facture/doc/pdf_crabe.modules.php | 2 +- .../fichinter/doc/pdf_soleil.modules.php | 2 +- .../livraison/pdf/pdf_typhon.modules.php | 52 +++++++++---------- .../project/pdf/pdf_baleine.modules.php | 2 +- .../modules/propale/doc/pdf_azur.modules.php | 2 +- .../modules/rapport/pdf_paiement.class.php | 2 +- .../pdf/pdf_canelle.modules.php | 2 +- .../pdf/pdf_muscadet.modules.php | 2 +- 13 files changed, 40 insertions(+), 40 deletions(-) diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index 1a04322d68b..1ae875fc7fb 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -145,7 +145,7 @@ class CommActionRapport $nbpage = $this->_pages($pdf, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); $pdf->Output($file,'F'); diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index c2023f10924..bec2b079883 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -161,7 +161,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts // Pied de page $this->_pagefoot($pdf,'',$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 538a5b02be8..2316396d370 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -471,7 +471,7 @@ class pdf_einstein extends ModelePDFCommandes // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index 42598a2094d..97cf267844c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -169,7 +169,7 @@ class pdf_expedition_merou extends ModelePdfExpedition $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Sending")); @@ -302,7 +302,7 @@ class pdf_expedition_merou extends ModelePdfExpedition // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index e3113689726..3f321607f86 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -155,7 +155,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Sending")); @@ -322,7 +322,7 @@ class pdf_expedition_rouget extends ModelePdfExpedition // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index d0c7a9972d8..b6909274ce5 100755 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -473,7 +473,7 @@ class pdf_crabe extends ModelePDFFactures // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 953466ec88a..a10b207523f 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -320,7 +320,7 @@ class pdf_soleil extends ModelePDFFicheinter } $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index adf1b8689b1..a55401156f4 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -162,7 +162,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $dir = $conf->expedition->dir_output."/receipt/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } - + if (! file_exists($dir)) { if (dol_mkdir($dir) < 0) @@ -175,7 +175,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if (file_exists($dir)) { $nblines = count($object->lines); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance @@ -288,7 +288,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $curX = $this->posxdesc-1; $showpricebeforepagebreak=1; - + $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxcomm-$curX,3,$curX,$curY,$hideref,$hidedesc); $pageposafter=$pdf->getPage(); @@ -320,7 +320,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder { $pdf->commitTransaction(); } - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); $pdf->setPage($pageposbefore); @@ -429,11 +429,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Affiche zone infos $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); - + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + // Check product remaining to be delivered // TODO doit etre modifie //$waitingDelivery = $object->getRemainingDelivered(); @@ -492,7 +492,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); }*/ $pdf->Close(); @@ -539,20 +539,20 @@ class pdf_typhon extends ModelePDFDeliveryOrder { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); - + $pdf->SetFont('','', $default_font_size); $pdf->SetXY($this->marge_gauche, $posy); - + $larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3; $pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->SetXY($this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign,2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":",'','L'); - + $pdf->Rect(2*$larg_sign+$this->marge_gauche, $posy + 1, $larg_sign, 25); $pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $posy + 2); $pdf->MultiCell($larg_sign,2, $outputlangs->trans("ForCustomer").':','','L'); } - + /** * Show table for lines * @@ -568,13 +568,13 @@ class pdf_typhon extends ModelePDFDeliveryOrder function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) { global $conf,$mysoc; - + // Force to disable hidetop and hidebottom $hidebottom=0; if ($hidetop) $hidetop=-1; - + $default_font_size = pdf_getPDFFontSize($outputlangs); - + // Amount in (at tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -586,11 +586,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder { $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); } - + $pdf->SetDrawColor(128,128,128); $pdf->SetFont('','', $default_font_size - 1); - if (empty($hidetop)) + if (empty($hidetop)) { $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell($this->posxcomm - $this->posxdesc,2, $outputlangs->transnoentities("Designation"),'','L'); @@ -634,15 +634,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder { pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); } - + $pdf->SetTextColor(0,0,60); $pdf->SetFont('','B', $default_font_size + 3); - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-100; - + $pdf->SetXY($this->marge_gauche,$posy); - + // Logo $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) @@ -694,21 +694,21 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetTextColor(0,0,60); $posy+=2; - + // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - + if ($showaddress) { // Sender properties $carac_emetteur = pdf_build_address($outputlangs,$this->emetteur); - + // Show sender $posy=42; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; $hautcadre=40; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -728,7 +728,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $pdf->SetXY($posx+2,$posy+8); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - + // Client destinataire $posy=42; $pdf->SetTextColor(0,0,0); diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php index 1befddf2168..a09ee857a96 100644 --- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php @@ -287,7 +287,7 @@ class pdf_baleine extends ModelePDFProjects * Pied de page */ $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index ed63d09715b..03864e1a572 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -471,7 +471,7 @@ class pdf_azur extends ModelePDFPropales // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 8ef322a0a0c..b7e2f8e5d91 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -210,7 +210,7 @@ class pdf_paiement $this->Body($pdf, 1, $lines, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 1477b202878..1d04d8f3165 100755 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -407,7 +407,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 4141190f451..0227ae8187a 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -425,7 +425,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); - $pdf->AliasNbPages(); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); $pdf->Close();