From f5637463105ecc51c0c7b4dbf1de1d1e80c0ed43 Mon Sep 17 00:00:00 2001 From: Quentin Vial-Gouteyron Date: Mon, 29 May 2017 15:38:40 +0200 Subject: [PATCH 1/3] NEW_extrafield_in_project_mask --- htdocs/core/lib/functions2.lib.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) mode change 100644 => 100755 htdocs/core/lib/functions2.lib.php diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php old mode 100644 new mode 100755 index 8934447fdfe..69ee228504d --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -711,7 +711,7 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti */ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true) { - global $conf; + global $conf,$user; if (! is_object($objsoc)) $valueforccc=$objsoc; else if($table == "commande_fournisseur" || $table == "facture_fourn" ) $valueforccc=$objsoc->code_fournisseur; @@ -790,7 +790,16 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskpersonew[$regKey[1]]=str_pad('', '_', $regKey[2], STR_PAD_RIGHT); $tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew, $tmpmask); }*/ - + + if(strstr($mask,'extra_')){ + + $start = "{extra_"; + $end = "\}"; + $extra= get_string_between($mask, "extra_", "}"); + if(!empty($user->array_options['options_'.$extra])){ + $mask = preg_replace('#('.($start).')(.*?)('.($end).')#si', $user->array_options['options_'.$extra], $mask); + } + } $maskwithonlyymcode=$mask; $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode); @@ -1110,7 +1119,14 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m dol_syslog("functions2::get_next_value return ".$numFinal,LOG_DEBUG); return $numFinal; } - +function get_string_between($string, $start, $end){ + $string = " ".$string; + $ini = strpos($string,$start); + if ($ini == 0) return ""; + $ini += strlen($start); + $len = strpos($string,$end,$ini) - $ini; + return substr($string,$ini,$len); +} /** * Check value * From 21183f91a3f0c9eb2613ad74a3b5e1e6929e2a8e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 31 May 2017 05:27:39 +0200 Subject: [PATCH 2/3] FIX : Vat payment - Sql error / Add information in tooltip / Correct writting in general ledger --- htdocs/accountancy/journal/bankjournal.php | 30 +++++++++++++++--- htdocs/compta/tva/reglement.php | 36 ++++++++++++---------- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index ea98d678671..7bb1ef20923 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -284,7 +284,8 @@ if ($result) { $paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->label = $links[$key]['label']; - $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentVat"); + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); + $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; } else if ($links[$key]['type'] == 'payment_salary') { $paymentsalstatic->id = $links[$key]['url_id']; @@ -415,8 +416,11 @@ if (! $error && $action == 'writebookkeeping') { $objmid = $db->fetch_object($resultmid); $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport } - } - + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->code_tiers = ''; + $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment + } + $result = $bookkeeping->create($user); if ($result < 0) { if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists @@ -489,6 +493,10 @@ if (! $error && $action == 'writebookkeeping') { } $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; + } else if ($tabtype[$key] == 'payment_vat') { + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat } else if ($tabtype[$key] == 'banktransfert') { $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; @@ -724,6 +732,7 @@ if (empty($action) || $action == 'view') { $invoicestatic = new Facture($db); $invoicesupplierstatic = new FactureFournisseur($db); $expensereportstatic = new ExpenseReport($db); + $vatstatic = new Tva($db); llxHeader('', $langs->trans("FinanceJournal")); @@ -850,7 +859,20 @@ if (empty($action) || $action == 'view') { } else dol_print_error($db); } - + elseif ($tabtype[$key] == 'payment_vat') + { + $sqlmid = 'SELECT v.rowid as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; + $sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $vatstatic->fetch($objmid->id); + $ref=$langs->trans("PaymentVat").' '.$vatstatic->getNomUrl(1); + } + else dol_print_error($db); + } /*$invoicestatic->id = $key; $invoicestatic->ref = $val["ref"]; diff --git a/htdocs/compta/tva/reglement.php b/htdocs/compta/tva/reglement.php index 076978a86fb..8b4d3299f9c 100644 --- a/htdocs/compta/tva/reglement.php +++ b/htdocs/compta/tva/reglement.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2011-2014 Alexandre Spangaro + * Copyright (C) 2011-2017 Alexandre Spangaro * * 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 @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("compta"); $langs->load("bills"); @@ -94,10 +95,10 @@ llxHeader('', $langs->trans("VATPayments")); $form = new Form($db); $formother=new FormOther($db); $tva_static = new Tva($db); -$accountstatic = new Account($db); +$bankstatic = new Account($db); $sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,"; -$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; +$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; @@ -227,19 +228,22 @@ if ($result) { print ''; if ($obj->fk_bank > 0) - { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id=$obj->bid; - $accountstatic->ref=$obj->bref; - $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; - $accountstatic->label=$obj->blabel; - print $accountstatic->getNomUrl(1); - } - else print ' '; - print ''; - } + { + $bankstatic->id=$obj->bid; + $bankstatic->ref=$obj->bref; + $bankstatic->number=$obj->bnumber; + $bankstatic->account_number=$obj->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($obj->fk_accountancy_journal); + $bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + + $bankstatic->label=$obj->blabel; + print $bankstatic->getNomUrl(1); + } + else print ' '; + print ''; + } // Amount $total = $total + $obj->amount; print "".price($obj->amount).""; From a49174313f6bf6c6fa05b812c5a78258a65a1f66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 31 May 2017 19:45:54 +0200 Subject: [PATCH 3/3] Replace {extra_ with {user_extra_ --- htdocs/core/lib/functions2.lib.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 69ee228504d..c3d8714ab89 100755 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -790,16 +790,16 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskpersonew[$regKey[1]]=str_pad('', '_', $regKey[2], STR_PAD_RIGHT); $tmpmask=preg_replace('/\{'.$regKey[1].'\-'.$regKey[2].'\}/i', $maskpersonew, $tmpmask); }*/ - - if(strstr($mask,'extra_')){ - $start = "{extra_"; + if (strstr($mask,'user_extra_')) + { + $start = "{user_extra_"; $end = "\}"; - $extra= get_string_between($mask, "extra_", "}"); + $extra= get_string_between($mask, "user_extra_", "}"); if(!empty($user->array_options['options_'.$extra])){ - $mask = preg_replace('#('.($start).')(.*?)('.($end).')#si', $user->array_options['options_'.$extra], $mask); + $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); } - } + } $maskwithonlyymcode=$mask; $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode);