diff --git a/ChangeLog b/ChangeLog index f92c959db5063..dad4cb65c1ee4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ For users: - Fix: sql errors on updat fichinter - Fix: debian script syntax error - Fix: error "menu param is not inside list" into pos module. +- Fix: Salary payments are not reflected on the reporting sheets ***** ChangeLog for 3.6 compared to 3.5.* ***** For users: diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d68aa528122e5..26589be3c5d80 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014 Juanjo Menent * * 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 @@ -538,6 +539,69 @@ print ''; } +/* + * Salaries + */ + +print ''.$langs->trans("Salaries").''; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount, u.firstname, u.lastname, p.fk_user"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; +$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; +$sql.= " WHERE p.entity = ".$conf->entity; +if (! empty($date_start) && ! empty($date_end)) + $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + +$sql.= " GROUP BY u.rowid"; +$sql.= " ORDER BY u.firstname"; + +dol_syslog("get payment salaries sql=".$sql); +$result=$db->query($sql); +$subtotal_ht = 0; +$subtotal_ttc = 0; +if ($result) +{ + $num = $db->num_rows($result); + $var=true; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total_ht -= $obj->amount; + $total_ttc -= $obj->amount; + $subtotal_ht += $obj->amount; + $subtotal_ttc += $obj->amount; + + $var = !$var; + print " "; + + print "".$langs->trans("Salaries")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; + + if ($modecompta == 'CREANCES-DETTES') print ''.price(-$obj->amount).''; + print ''.price(-$obj->amount).''; + print ''; + $i++; + } + } + else + { + $var = !$var; + print " "; + print ''.$langs->trans("None").''; + print ''; + } +} +else +{ + dol_print_error($db); +} +print ''; +if ($modecompta == 'CREANCES-DETTES') + print ''.price(-$subtotal_ht).''; +print ''.price(-$subtotal_ttc).''; +print ''; /* * VAT diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index b3a42d85a6bca..fdc9b0472f04b 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Ferran Marcet + * Copyright (C) 2014 Juanjo Menent * * 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 @@ -469,6 +470,44 @@ $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +/* + * Salaries + */ +$subtotal_ht = 0; +$subtotal_ttc = 0; +$sql = "SELECT p.label as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; +$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; +$sql.= " WHERE p.entity = ".$conf->entity; +$sql.= " GROUP BY p.label, dm"; + +dol_syslog("get social salaries payments sql=".$sql); +$result=$db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $var=false; + $i = 0; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + + if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; + $decaiss[$obj->dm] += $obj->amount; + + if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; + $decaiss_ttc[$obj->dm] += $obj->amount; + + $i++; + } + } +} +else +{ + dol_print_error($db); +} + /* * Show result array */ diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8806879aa4b54..9299702a1bb0e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1,10 +1,10 @@ - * Copyright (C) 2010-2012 Regis Houssin - * Copyright (c) 2010 Juanjo Menent - * Copyright (c) 2013 Charles-Fr BENKE - * Copyright (C) 2013 Cédric Salvador - * Copyright (c) 2014 Marcos García +/* Copyright (C) 2008-2013 Laurent Destailleur + * Copyright (C) 2010-2014 Regis Houssin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2013 Charles-Fr BENKE + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2014 Marcos García * * 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 @@ -270,7 +270,7 @@ function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed if (! empty($iconPDF)) { return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir); } - $printer = ($user->rights->printipp->read && $conf->printipp->enabled)?true:false; + $printer = (!empty($user->rights->printipp->read) && !empty($conf->printipp->enabled))?true:false; $hookmanager->initHooks(array('formfile')); $forname='builddoc'; $out=''; @@ -514,11 +514,11 @@ function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed $out.= $genbutton; $out.= ''; - if($hookmanager->hooks['formfile']) + if (!empty($hookmanager->hooks['formfile'])) { foreach($hookmanager->hooks['formfile'] as $module) { - if(method_exists($module, 'formBuilddocLineOptions')) $out .= ''; + if (method_exists($module, 'formBuilddocLineOptions')) $out .= ''; } } $out.= '';