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

develop

Conflicts:
	htdocs/core/class/commondocgenerator.class.php
This commit is contained in:
Laurent Destailleur 2018-10-24 03:39:33 +02:00
commit 65a39269d9
9 changed files with 192 additions and 115 deletions

View File

@ -1,13 +1,14 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Thibault FOUCART <support@ptibogxiv.net> * Copyright (C) 2018 Thibault FOUCART <support@ptibogxiv.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -73,16 +74,69 @@ class Paiement extends CommonObject
public $author; public $author;
public $paiementid; // Type de paiement. Stocke dans fk_paiement public $paiementid; // Type de paiement. Stocke dans fk_paiement
// de llx_paiement qui est lie aux types de // de llx_paiement qui est lie aux types de
//paiement de llx_c_paiement //paiement de llx_c_paiement
public $num_paiement; // Numero du CHQ, VIR, etc...
public $num_payment; // Numero du CHQ, VIR, etc... /**
public $payment_id; // Id of external modepayment * @var string type libelle
public $payment_site; // name of external modepayment */
public $bank_account; // Id compte bancaire du paiement public $type_libelle;
public $bank_line; // Id de la ligne d'ecriture bancaire
/**
* @var string type code
*/
public $type_code;
/**
* @var string Numero du CHQ, VIR, etc...
* @deprecated
* @see num_payment
*/
public $numero;
/**
* @var string Numero du CHQ, VIR, etc...
* @deprecated
* @see num_payment
*/
public $num_paiement;
/**
* @var string Numero du CHQ, VIR, etc...
*/
public $num_payment;
/**
* @var string Id of external payment mode
*/
public $ext_payment_id;
/**
* @var string Name of external payment mode
*/
public $ext_payment_site;
/**
* @var int bank account id of payment
* @deprecated
*/
public $bank_account;
/**
* @var int bank account id of payment
*/
public $fk_account;
/**
* @var int id of payment line in bank account
*/
public $bank_line;
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
// fk_paiement dans llx_paiement_facture est le rowid du paiement // fk_paiement dans llx_paiement_facture est le rowid du paiement
public $fk_paiement; // Type of paiment /**
* @var int payment id
*/
public $fk_paiement; // Type of payment
/** /**
@ -90,7 +144,7 @@ class Paiement extends CommonObject
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
@ -103,7 +157,7 @@ class Paiement extends CommonObject
* @param int $fk_bank Id of bank line associated to payment * @param int $fk_bank Id of bank line associated to payment
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
function fetch($id, $ref='', $fk_bank='') public function fetch($id, $ref='', $fk_bank='')
{ {
$sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank,'; $sql = 'SELECT p.rowid, p.ref, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank,';
$sql.= ' c.code as type_code, c.libelle as type_libelle,'; $sql.= ' c.code as type_code, c.libelle as type_libelle,';
@ -138,8 +192,8 @@ class Paiement extends CommonObject
$this->type_libelle = $obj->type_libelle; $this->type_libelle = $obj->type_libelle;
$this->type_code = $obj->type_code; $this->type_code = $obj->type_code;
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->payment_id = $obj->ext_payment_id; $this->ext_payment_id = $obj->ext_payment_id;
$this->payment_site = $obj->ext_payment_site; $this->ext_payment_site = $obj->ext_payment_site;
$this->bank_account = $obj->fk_account; // deprecated $this->bank_account = $obj->fk_account; // deprecated
$this->fk_account = $obj->fk_account; $this->fk_account = $obj->fk_account;
@ -235,7 +289,7 @@ class Paiement extends CommonObject
$note = ($this->note_public?$this->note_public:$this->note); $note = ($this->note_public?$this->note_public:$this->note);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat)";
$sql.= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($note)."', ".($this->payment_id?"'".$this->db->escape($this->payment_id)."'":"null").", ".($this->payment_site?"'".$this->db->escape($this->payment_site)."'":"null").", ".$user->id.")"; $sql.= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($note)."', ".($this->ext_payment_id?"'".$this->db->escape($this->ext_payment_id)."'":"null").", ".($this->ext_payment_site?"'".$this->db->escape($this->ext_payment_site)."'":"null").", ".$user->id.")";
dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG); dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -1,10 +1,11 @@
<?php <?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com> * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1017,7 +1018,7 @@ abstract class CommonDocGenerator
$parameters=array( $parameters=array(
'object' => $object, 'object' => $object,
'curY' =>& $curY, 'curY' => &$curY,
'columnText' => $columnText, 'columnText' => $columnText,
'colKey' => $colKey 'colKey' => $colKey
); );
@ -1030,7 +1031,6 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey]; $colDef = $this->cols[$colKey];
$pdf->MultiCell( $this->getColumnContentWidth($colKey),2, $columnText,'',$colDef['content']['align']); $pdf->MultiCell( $this->getColumnContentWidth($colKey),2, $columnText,'',$colDef['content']['align']);
} }
} }

View File

@ -7,6 +7,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -67,7 +68,7 @@ class pdf_eratosthene extends ModelePDFCommandes
public $type; public $type;
/** /**
* @var array() Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.3 = array(5, 3) * e.g.: PHP ≥ 5.3 = array(5, 3)
*/ */
public $phpmin = array(5, 2); public $phpmin = array(5, 2);
@ -145,7 +146,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->atleastonediscount=0; $this->atleastonediscount=0;
} }
/** phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
@ -156,7 +158,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
@ -665,16 +667,16 @@ class pdf_eratosthene extends ModelePDFCommandes
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Affiche zone infos // Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux // Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); $posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements // Affiche zone versements
/* /*
if ($deja_regle) if ($deja_regle)
{ {
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
} }
*/ */
@ -721,7 +723,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Translate $outputlangs Object langs for output * @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function _tableau_versements(&$pdf, $object, $posy, $outputlangs) private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
@ -737,7 +739,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @return void * @return void
*/ */
function _tableau_info(&$pdf, $object, $posy, $outputlangs) private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@ -925,7 +927,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Translate $outputlangs Objet langs * @param Translate $outputlangs Objet langs
* @return int Position pour suite * @return int Position pour suite
*/ */
function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf,$mysoc; global $conf,$mysoc;
@ -1189,7 +1191,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param string $currency Currency code * @param string $currency Currency code
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
{ {
global $conf; global $conf;
@ -1245,8 +1247,6 @@ class pdf_eratosthene extends ModelePDFCommandes
if (empty($hidetop)){ if (empty($hidetop)){
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
} }
} }
/** /**
@ -1259,7 +1259,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param string $titlekey Translation key to show as title of document * @param string $titlekey Translation key to show as title of document
* @return void * @return void
*/ */
function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle") private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
{ {
global $conf,$langs,$hookmanager; global $conf,$langs,$hookmanager;
@ -1470,7 +1470,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $hidefreetext 1=Hide free text * @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text * @return int Return height of bottom margin including footer text
*/ */
function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
{ {
global $conf; global $conf;
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
@ -1489,9 +1489,8 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return null * @return null
*/ */
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0) public function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{ {
global $conf, $hookmanager; global $conf, $hookmanager;
// Default field style for content // Default field style for content
@ -1677,7 +1676,5 @@ class pdf_eratosthene extends ModelePDFCommandes
{ {
$this->cols = $hookmanager->resArray; $this->cols = $hookmanager->resArray;
} }
} }
} }

View File

@ -8,6 +8,7 @@
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -68,7 +69,7 @@ class pdf_sponge extends ModelePDFFactures
public $type; public $type;
/** /**
* @var array() Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.3 = array(5, 3) * e.g.: PHP ≥ 5.3 = array(5, 3)
*/ */
public $phpmin = array(5, 2); public $phpmin = array(5, 2);
@ -159,7 +160,8 @@ class pdf_sponge extends ModelePDFFactures
} }
/** phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
@ -170,7 +172,7 @@ class pdf_sponge extends ModelePDFFactures
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
{ {
// phpcs:enable // phpcs:enable
global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
@ -801,15 +803,15 @@ class pdf_sponge extends ModelePDFFactures
} }
// Affiche zone infos // Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux // Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); $posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements // Affiche zone versements
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
{ {
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
} }
// Pied de page // Pied de page
@ -856,7 +858,7 @@ class pdf_sponge extends ModelePDFFactures
* @param Translate $outputlangs Object langs for output * @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function _tableau_versements(&$pdf, $object, $posy, $outputlangs) function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@ -984,7 +986,6 @@ class pdf_sponge extends ModelePDFFactures
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
return -1; return -1;
} }
} }
@ -997,7 +998,7 @@ class pdf_sponge extends ModelePDFFactures
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @return void * @return void
*/ */
function _tableau_info(&$pdf, $object, $posy, $outputlangs) private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@ -1156,7 +1157,7 @@ class pdf_sponge extends ModelePDFFactures
* @param Translate $outputlangs Objet langs * @param Translate $outputlangs Objet langs
* @return int Position pour suite * @return int Position pour suite
*/ */
function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf,$mysoc; global $conf,$mysoc;
@ -1536,8 +1537,6 @@ class pdf_sponge extends ModelePDFFactures
if (empty($hidetop)){ if (empty($hidetop)){
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
} }
} }
/** /**
@ -1842,9 +1841,8 @@ class pdf_sponge extends ModelePDFFactures
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return null * @return null
*/ */
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0) function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{ {
global $conf, $hookmanager; global $conf, $hookmanager;
// Default field style for content // Default field style for content
@ -2031,8 +2029,5 @@ class pdf_sponge extends ModelePDFFactures
{ {
$this->cols = $hookmanager->resArray; $this->cols = $hookmanager->resArray;
} }
} }
} }

View File

@ -7,6 +7,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -40,24 +41,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/ */
class pdf_cyan extends ModelePDFPropales class pdf_cyan extends ModelePDFPropales
{ {
var $db; public $db;
var $name; public $name;
var $description; public $description;
var $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template public $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
var $type; public $type;
var $phpmin = array(4,3,0); // Minimum version of PHP required by module public $phpmin = array(4,3,0); // Minimum version of PHP required by module
var $version = 'development'; public $version = 'development';
var $page_largeur; public $page_largeur;
var $page_hauteur; public $page_hauteur;
var $format; public $format;
var $marge_gauche; public $marge_gauche;
var $marge_droite; public $marge_droite;
var $marge_haute; public $marge_haute;
var $marge_basse; public $marge_basse;
var $emetteur; // Objet societe qui emet public $emetteur; // Objet societe qui emet
/** /**
@ -65,7 +66,7 @@ class pdf_cyan extends ModelePDFPropales
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
@ -117,7 +118,8 @@ class pdf_cyan extends ModelePDFPropales
$this->atleastonediscount=0; $this->atleastonediscount=0;
} }
/** phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
@ -128,9 +130,9 @@ class pdf_cyan extends ModelePDFPropales
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
{ {
// phpcs:enable // phpcs:enable
global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
if (! is_object($outputlangs)) $outputlangs=$langs; if (! is_object($outputlangs)) $outputlangs=$langs;
@ -746,23 +748,23 @@ class pdf_cyan extends ModelePDFPropales
} }
// Affiche zone infos // Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux // Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); $posy=$this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
// Affiche zone versements // Affiche zone versements
/* /*
if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
{ {
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
} }
*/ */
// Customer signature area // Customer signature area
if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
{ {
$posy=$this->_signature_area($pdf, $object, $posy, $outputlangs); $posy=$this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
} }
// Pied de page // Pied de page
@ -882,7 +884,7 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Object langs for output * @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function _tableau_versements(&$pdf, $object, $posy, $outputlangs) private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
} }
@ -897,7 +899,7 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @return void * @return void
*/ */
function _tableau_info(&$pdf, $object, $posy, $outputlangs) function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@ -1078,7 +1080,7 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Objet langs * @param Translate $outputlangs Objet langs
* @return int Position pour suite * @return int Position pour suite
*/ */
function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{ {
global $conf,$mysoc; global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -1412,8 +1414,6 @@ class pdf_cyan extends ModelePDFPropales
if (empty($hidetop)){ if (empty($hidetop)){
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
} }
} }
/** /**
@ -1666,7 +1666,7 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Objet langs * @param Translate $outputlangs Objet langs
* @return int Position pour suite * @return int Position pour suite
*/ */
function _signature_area(&$pdf, $object, $posy, $outputlangs) private function drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
{ {
global $conf; global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -1703,9 +1703,8 @@ class pdf_cyan extends ModelePDFPropales
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return null * @return null
*/ */
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0) function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{ {
global $conf, $hookmanager; global $conf, $hookmanager;
// Default field style for content // Default field style for content
@ -1891,7 +1890,5 @@ class pdf_cyan extends ModelePDFPropales
{ {
$this->cols = $hookmanager->resArray; $this->cols = $hookmanager->resArray;
} }
} }
} }

View File

@ -71,6 +71,9 @@ if ($action == 'setvalue' && $user->admin)
if (! $result > 0) $error++; if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE",GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity); $result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE",GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++; if (! $result > 0) $error++;
$result=dolibarr_set_const($db, "PAYBOX_HMAC_KEY", dol_encode(GETPOST('PAYBOX_HMAC_KEY','alpha')),'chaine',0,'',$conf->entity);
if (! $result > 0) $error++;
if (! $error) if (! $error)
{ {
@ -145,6 +148,12 @@ print '<input size="32" type="text" name="PAYBOX_PBX_IDENTIFIANT" value="'.$conf
print '<br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')'; print '<br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')';
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven"><td>';
print '<span class="fieldrequired">'.$langs->trans("PAYBOX_HMAC_KEY").'</span></td><td>';
print '<input size="100" type="text" name="PAYBOX_HMAC_KEY" value="'.dol_decode($conf->global->PAYBOX_HMAC_KEY).'">';
print '<br>'.$langs->trans("Example").': 2 ('.$langs->trans("Test").')';
print '</td></tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("UsageParameter").'</td>'; print '<td>'.$langs->trans("UsageParameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>'; print '<td>'.$langs->trans("Value").'</td>';

View File

@ -92,16 +92,41 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
$IBS_REFUSE=$urlko; $IBS_REFUSE=$urlko;
$IBS_BKGD="#FFFFFF"; $IBS_BKGD="#FFFFFF";
$IBS_WAIT="2000"; $IBS_WAIT="2000";
$IBS_LANG="GBR"; // By default GBR=english (FRA, GBR, ESP, ITA et DEU...) $IBS_LANG="GBR"; // By default GBR=english (FRA, GBR, ESP, ITA et DEU...)
if (preg_match('/^FR/i',$langs->defaultlang)) $IBS_LANG="FRA"; if (preg_match('/^FR/i',$langs->defaultlang)) $IBS_LANG="FRA";
if (preg_match('/^ES/i',$langs->defaultlang)) $IBS_LANG="ESP"; if (preg_match('/^ES/i',$langs->defaultlang)) $IBS_LANG="ESP";
if (preg_match('/^IT/i',$langs->defaultlang)) $IBS_LANG="ITA"; if (preg_match('/^IT/i',$langs->defaultlang)) $IBS_LANG="ITA";
if (preg_match('/^DE/i',$langs->defaultlang)) $IBS_LANG="DEU"; if (preg_match('/^DE/i',$langs->defaultlang)) $IBS_LANG="DEU";
if (preg_match('/^NL/i',$langs->defaultlang)) $IBS_LANG="NLD"; if (preg_match('/^NL/i',$langs->defaultlang)) $IBS_LANG="NLD";
if (preg_match('/^SE/i',$langs->defaultlang)) $IBS_LANG="SWE"; if (preg_match('/^SE/i',$langs->defaultlang)) $IBS_LANG="SWE";
$IBS_OUTPUT='E'; $IBS_OUTPUT='E';
$PBX_SOURCE='HTML'; $PBX_SOURCE='HTML';
$PBX_TYPEPAIEMENT='CARTE'; $PBX_TYPEPAIEMENT='CARTE';
$msg = "PBX_IDENTIFIANT=".$PBX_IDENTIFIANT.
"&PBX_MODE=".$IBS_MODE.
"&PBX_SITE=".$IBS_SITE.
"&PBX_RANG=".$IBS_RANG.
"&PBX_TOTAL=".$IBS_TOTAL.
"&PBX_DEVISE=".$IBS_DEVISE.
"&PBX_CMD=".$IBS_CMD.
"&PBX_PORTEUR=".$IBS_PORTEUR.
"&PBX_RETOUR=".$IBS_RETOUR.
"&PBX_EFFECTUE=".$IBS_EFFECTUE.
"&PBX_ANNULE=".$IBS_ANNULE.
"&PBX_REFUSE=".$IBS_REFUSE.
"&PBX_TXT=".$IBS_TXT.
"&PBX_BKGD=".$IBS_BKGD.
"&PBX_WAIT=".$IBS_WAIT.
"&PBX_LANGUE=".$IBS_LANG.
"&PBX_OUTPUT=".$IBS_OUTPUT.
"&PBX_SOURCE=".$PBX_SOURCE.
"&PBX_TYPEPAIEMENT=".$PBX_TYPEPAIEMENT;
$binKey = pack("H*", dol_decode($conf->global->PAYBOX_HMAC_KEY));
$hmac = strtoupper(hash_hmac('sha512', $msg, $binKey));
dol_syslog("Soumission Paybox", LOG_DEBUG); dol_syslog("Soumission Paybox", LOG_DEBUG);
dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG); dol_syslog("IBS_MODE: $IBS_MODE", LOG_DEBUG);
@ -157,7 +182,7 @@ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG)
print '<input type="hidden" name="PBX_OUTPUT" value="'.$IBS_OUTPUT.'">'."\n"; print '<input type="hidden" name="PBX_OUTPUT" value="'.$IBS_OUTPUT.'">'."\n";
print '<input type="hidden" name="PBX_SOURCE" value="'.$PBX_SOURCE.'">'."\n"; print '<input type="hidden" name="PBX_SOURCE" value="'.$PBX_SOURCE.'">'."\n";
print '<input type="hidden" name="PBX_TYPEPAIEMENT" value="'.$PBX_TYPEPAIEMENT.'">'."\n"; print '<input type="hidden" name="PBX_TYPEPAIEMENT" value="'.$PBX_TYPEPAIEMENT.'">'."\n";
print '<input type="hidden" name="PBX_HMAC" value="'.$hmac.'">'."\n";
print '</form>'."\n"; print '</form>'."\n";

View File

@ -630,8 +630,8 @@ if ($ispaymentok)
$paiement->paiementid = $paymentTypeId; $paiement->paiementid = $paymentTypeId;
$paiement->num_paiement = ''; $paiement->num_paiement = '';
$paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress;
$paiement->payment_id = $TRANSACTIONID; $paiement->ext_payment_id = $TRANSACTIONID;
$paiement->payment_site = $paymentmethod; $paiement->ext_payment_site = $paymentmethod;
if (! $error) if (! $error)
{ {
@ -653,8 +653,8 @@ if ($ispaymentok)
{ {
$bankaccountid = 0; $bankaccountid = 0;
if ($paymentmethod == 'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; if ($paymentmethod == 'paybox') $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS;
if ($paymentmethod == 'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; elseif ($paymentmethod == 'paypal') $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS;
if ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; elseif ($paymentmethod == 'stripe') $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS;
if ($bankaccountid > 0) if ($bankaccountid > 0)
{ {
@ -873,8 +873,8 @@ else
if (! empty($conf->global->PAYMENTONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYMENTONLINE_SENDEMAIL; if (! empty($conf->global->PAYMENTONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYMENTONLINE_SENDEMAIL;
// TODO Remove local option to keep only the generic one ? // TODO Remove local option to keep only the generic one ?
if ($paymentmethod == 'paypal' && ! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; if ($paymentmethod == 'paypal' && ! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL;
if ($paymentmethod == 'paybox' && ! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; elseif ($paymentmethod == 'paybox' && ! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL;
if ($paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->STRIPE_PAYONLINE_SENDEMAIL; elseif ($paymentmethod == 'stripe' && ! empty($conf->global->STRIPE_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->STRIPE_PAYONLINE_SENDEMAIL;
// Send an email // Send an email
if ($sendemail) if ($sendemail)

View File

@ -3271,7 +3271,7 @@ ul.noborder li:nth-child(even):not(.liste_titre) {
.boxstats130 { .boxstats130 {
width: 158px; width: 158px;
height: 48px; height: 48px;
padding: 3px padding: 3px;
} }
.boxstats { .boxstats {
padding: 3px; padding: 3px;