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

This commit is contained in:
Laurent Destailleur 2017-05-05 12:34:22 +02:00
commit 65e03ca3ba
6 changed files with 271 additions and 168 deletions

View File

@ -365,27 +365,62 @@ class AccountingAccount extends CommonObject
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @return string Chaine avec URL * @param int $withlabel 0=No label, 1=Include label of account
* @param int $nourl 1=Disable url
* @param string $moretitle Add more text to title tooltip
* @param int $notooltip 1=Disable tooltip
* @return string String with URL
*/ */
function getNomUrl($withpicto = 0) { function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0)
global $langs; {
global $langs, $conf, $user;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = ''; $result = '';
$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id . '">'; $url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
$linkend = '</a>';
$picto = 'billr'; $picto = 'billr';
$label='';
$label = $langs->trans("Show") . ': ' . $this->account_number . ' - ' . $this->label; $label = '<u>' . $langs->trans("ShowAccountingAccount") . '</u>';
if (! empty($this->account_number))
$label .= '<br><b>'.$langs->trans('AccountAccounting') . ':</b> ' . length_accountg($this->account_number);
if (! empty($this->label))
$label .= '<br><b>'.$langs->trans('Label') . ':</b> ' . $this->label;
if ($moretitle) $label.=' - '.$moretitle;
if ($withpicto) $linkclose='';
$result .= ($link . img_object($label, $picto) . $linkend); if (empty($notooltip))
if ($withpicto && $withpicto != 2) {
$result .= ' '; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
if ($withpicto != 2) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label=$langs->trans("ShowAccoutingAccount");
$result .= $link . length_accountg($this->account_number) . ' - ' . $this->label . $linkend; $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
}
$linkstart='<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
if ($nourl)
{
$linkstart = '';
$linkclose = '';
$linkend = '';
}
$label_link = length_accountg($this->account_number);
if ($withlabel) $label_link .= ' - ' . $this->label;
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto && $withpicto != 2) $result .= ' ';
if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend;
return $result; return $result;
} }

View File

@ -1366,30 +1366,58 @@ class Propal extends CommonObject
$this->lines = array(); $this->lines = array();
/* /*
* Lignes propales liees a un produit ou non * Lines
*/ */
$sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $result=$this->fetch_lines();
$sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; if ($result < 0)
$sql.= " d.fk_unit,"; {
return -3;
}
return 1;
}
$this->error="Record Not Found";
return 0;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/**
* Load array lines
*
* @param int $only_product Return only physical products
* @return int <0 if KO, >0 if OK
*/
function fetch_lines($only_product=0)
{
$this->lines=array();
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
$sql.= ' d.fk_unit,';
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
$sql.= ' d.date_start, d.date_end'; $sql.= ' d.date_start, d.date_end';
$sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; $sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as d';
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (d.fk_product = p.rowid)';
$sql.= " WHERE d.fk_propal = ".$this->id; $sql.= ' WHERE d.fk_propal = '.$this->id;
$sql.= " ORDER by d.rang"; if ($only_product) $sql .= ' AND p.fk_product_type = 0';
$sql.= ' ORDER by d.rang';
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline=new ExtraFields($this->db);
$line = new PropaleLigne($this->db);
$extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element,true);
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$i = 0;
$i = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
@ -1447,32 +1475,22 @@ class Propal extends CommonObject
$line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$line->fetch_optionals($line->id,$extralabelsline); $line->fetch_optionals();
$this->lines[$i] = $line; $this->lines[$i] = $line;
//dol_syslog("1 ".$line->fk_product); //dol_syslog("1 ".$line->fk_product);
//print "xx $i ".$this->lines[$i]->fk_product; //print "xx $i ".$this->lines[$i]->fk_product;
$i++; $i++;
} }
$this->db->free($result);
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
$this->db->free($result);
return 1; return 1;
} }
$this->error="Record Not Found";
return 0;
}
else else
{ {
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
return -1; return -3;
} }
} }

View File

@ -3,7 +3,7 @@
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2014-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* *
@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbank.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
$langs->load("banks"); $langs->load("banks");
$langs->load("bills"); $langs->load("bills");
@ -664,7 +664,10 @@ else
print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>'; print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
print '<td>'; print '<td>';
if (! empty($conf->accounting->enabled)) { if (! empty($conf->accounting->enabled)) {
print length_accountg($object->account_number).'</td></tr>'; $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('',$object->account_number);
print $accountingaccount->getNomUrl(0,1,1,'',1);
} else { } else {
print $object->account_number; print $object->account_number;
} }
@ -683,13 +686,11 @@ else
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright">'; print '<div class="fichehalfright">';
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Categories // Categories
@ -704,7 +705,6 @@ else
print '</table>'; print '</table>';
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT)
{ {
print '<br>'; print '<br>';

View File

@ -406,6 +406,50 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
$outputlangs->setDefaultLang($newlang); $outputlangs->setDefaultLang($newlang);
} }
if(!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) {
// Create output dir if not exists
dol_mkdir($diroutputmassaction);
// Defined name of merged file
$filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
$filename=preg_replace('/\s/','_',$filename);
// Save merged file
if ($filter=='paye:0')
{
if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
}
if ($year) $filename.='_'.$year;
if ($month) $filename.='_'.$month;
if (count($files)>0)
{
$now=dol_now();
$file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf';
$input_files = '';
foreach($files as $f) {
$input_files.=' '.escapeshellarg($f);
}
$cmd = 'pdftk '.$input_files.' cat output '.escapeshellarg($file);
exec($cmd);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$langs->load("exports");
setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
}
else
{
setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
}
}
else {
// Create empty PDF // Create empty PDF
$pdf=pdf_getInstance(); $pdf=pdf_getInstance();
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
@ -461,6 +505,7 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
{ {
setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors'); setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
} }
}
} }
// Remove a file from massaction area // Remove a file from massaction area

View File

@ -128,6 +128,8 @@ class FactureFournisseur extends CommonInvoice
public $multicurrency_total_ht; public $multicurrency_total_ht;
public $multicurrency_total_tva; public $multicurrency_total_tva;
public $multicurrency_total_ttc; public $multicurrency_total_ttc;
//! id of source invoice if replacement invoice or credit note
public $fk_facture_source;
/** /**
* Standard invoice * Standard invoice
@ -263,6 +265,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", fk_multicurrency"; $sql.= ", fk_multicurrency";
$sql.= ", multicurrency_code"; $sql.= ", multicurrency_code";
$sql.= ", multicurrency_tx"; $sql.= ", multicurrency_tx";
$sql.= ", fk_facture_source";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
@ -286,6 +289,7 @@ class FactureFournisseur extends CommonInvoice
$sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx; $sql.= ", ".(double) $this->multicurrency_tx;
$sql.= ", ".(isset($this->fk_facture_source)?$this->fk_facture_source:"NULL");
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);

View File

@ -59,6 +59,7 @@ ChangeAndLoad=Change and load
Addanaccount=Add an accounting account Addanaccount=Add an accounting account
AccountAccounting=Accounting account AccountAccounting=Accounting account
AccountAccountingShort=Account AccountAccountingShort=Account
ShowAccoutingAccount=Show accounting account
AccountAccountingSuggest=Accounting account suggested AccountAccountingSuggest=Accounting account suggested
MenuDefaultAccounts=Default accounts MenuDefaultAccounts=Default accounts
MenuVatAccounts=Vat accounts MenuVatAccounts=Vat accounts