diff --git a/ChangeLog b/ChangeLog index f94820c21cd4994932746dc1b2f12bb166600ea3..c4b334c542aebed2b21eda1b22e171c3644628cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -151,6 +151,12 @@ Fix: [ bug #1544 ] Can remove date from invoice. Fix: list event view lost type event filter. Fix: Add code save on create event. Fix: SQL injection. +Fix: [ bug #1589 ] Menu type in "Edit menu" page is not translated +Fix: [ bug #1591 ] Linked object block shows Total HT/TTC even if not having permission to read them +Fix: [ bug #1577 ] When creating new Private individual third, selected third type is ignored +Fix: [ bug #1555 ] Update accountancy code of products does not throw PRODUCT_MODIFY trigger +Fix: [ bug #1548 ] Supplier payment card shows type in French +Fix: [ bug #1546 ] Incorrect page number when searching in the list of bank transactions ***** ChangeLog for 3.5.4 compared to 3.5.3 ***** Fix: Hide title of event when agenda module disabled. diff --git a/build/debian/control b/build/debian/control index d22f556acaabf7839bed7cde82aeb1f446bb97ab..f4f9e12aa58c2303230efd76e2a16214c7a0a070 100755 --- a/build/debian/control +++ b/build/debian/control @@ -39,7 +39,7 @@ Description: Web based software to manage a company or foundation It's a web software you can install as a standalone program or on any web hosting provider to use it from anywhere with any web browser. . - Dolibarr was designed to be easy to use. Only the features that you need + Dolibarr was designed to be easy to use. Only the features that you need are visible, depending on which modules were activated. . This is an example of most common used modules: diff --git a/build/debian/copyright b/build/debian/copyright index d75283b535aa0b0b25e460dba0919b9e28406472..7310915203439578130b0b40d6412790becca8c3 100644 --- a/build/debian/copyright +++ b/build/debian/copyright @@ -61,7 +61,7 @@ License: GPL-3+ Files: htdocs/includes/adodbtime/* Copyright: 2003-2005, John Lim unknown, jackbbs -License: BSD +License: BSD-3-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -272,7 +272,7 @@ Comment: Files: htdocs/includes/jquery/plugins/flot/* Copyright: Flot team -License: Public Domain +License: Public-Domain This work is not subject to copyright in any jurisdiction Comment: Those files are not shipped in the binary package because we configure diff --git a/build/debian/get-orig-source.sh b/build/debian/get-orig-source.sh index 57f87ab1999aa2d7e6f1550933341b202eb2e3c9..418bbbc2199cde18a77ad3b89ff656b431db679e 100755 --- a/build/debian/get-orig-source.sh +++ b/build/debian/get-orig-source.sh @@ -8,16 +8,20 @@ echo "tmpdir = $tmpdir" if [ -n "$1" ]; then uscan_opts="--download-version=$1" fi -uscan --noconf --force-download --no-symlink --verbose --destdir=$tmpdir $uscan_opts +#uscan --noconf --force-download --no-symlink --verbose --destdir=$tmpdir $uscan_opts cd $tmpdir +# Other method to download (comment uscan if you use this) +wget http://www.dolibarr.org/files/stable/standard/dolibarr-3.5.4.tgz + +# Rename file to add +dfsg tgzfile=$(echo *.tgz) version=$(echo "$tgzfile" | perl -pi -e 's/^dolibarr-//; s/\.tgz$//; s/_/./g; s/\+nmu1//; ') cd - >/dev/null mv $tmpdir/dolibarr-${version}.tgz ../ -echo "File ../dolibarr-${version}.tgz is ready for git-import" +echo "File ../dolibarr-${version}.tgz is ready for git-import-orig" rm -rf $tmpdir diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index d99a02308b7abb4fee083e508d84ea381ee6ca8b..353cf3eaabe814d439bc3571207d04677b92fdc8 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -317,7 +317,7 @@ if ($action == 'create') print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>'; if ($parent_rowid) { - print 'Left'; + print $langs->trans('Left'); print '<input type="hidden" name="type" value="left">'; } else diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 632dee6396547a33d146d44ee2c4503f4467c18b..cb920afd5fc76c8ee9141b10838930915dff5de1 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com> - * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -27,6 +28,8 @@ <?php +global $user; + $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; @@ -52,17 +55,23 @@ foreach($linkedObjectBlock as $object) <a href="<?php echo DOL_URL_ROOT.'/comm/propal.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowPropal"),"propal").' '.$object->ref; ?></a></td> <td><?php echo $object->ref_client; ?></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td> - <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php + if ($user->rights->propale->lire) { + $total = $total + $object->total_ht; + echo price($object->total_ht); + } ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $object->total_ht; } ?> <tr class="liste_total"> <td align="left" colspan="3"><?php echo $langs->trans('TotalHT'); ?></td> - <td align="right"><?php echo price($total); ?></td> + <td align="right"><?php + if ($user->rights->propale->lire) { + echo price($total); + } ?></td> <td> </td> </tr> </table> diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index c7d073501a3296e5f709abaee245b886778cf725..d2fe19c5b6f5255e45e68f0794373060cc2abc36 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -22,6 +23,8 @@ <?php +global $user; + $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; @@ -47,17 +50,23 @@ foreach($linkedObjectBlock as $object) <tr <?php echo $GLOBALS['bc'][$var]; ?> ><td> <a href="<?php echo DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowOrder"),"order").' '.$object->ref; ?></a></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td> - <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php + if ($user->rights->commande->lire) { + $total = $total + $object->total_ht; + echo price($object->total_ht); + } ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $object->total_ht; } ?> <tr class="liste_total"> <td align="left" colspan="2"><?php echo $langs->trans('TotalHT'); ?></td> - <td align="right"><?php echo price($total); ?></td> + <td align="right"><?php + if ($user->rights->commande->lire) { + echo price($total); + } ?></td> <td> </td> </tr> </table> diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 0e16f6744fde60a66c206c2ca3c2436b36727b2b..bd1928f3da459314bdb041c11b11487fe5ca72a9 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -5,7 +5,7 @@ * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es> - * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2012-2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * * This program is free software; you can redistribute it and/or modify @@ -259,17 +259,22 @@ if ($id > 0 || ! empty($ref)) //Total pages $totalPages = ceil($total_lines/$viewline); - if ($page > 0) - { - $limitsql = ($totalPages - $page) * $viewline; - if ($limitsql < $viewline) $limitsql = $viewline; - $nbline = $limitsql; - } - else - { + if ($totalPages == 0) { $page = 0; - $limitsql = $nbline; + } else { + + if ($page > 0) { + $limitsql = ($totalPages - $page) * $viewline; + if ($limitsql < $viewline) { + $limitsql = $viewline; + } + $nbline = $limitsql; + } else { + $page = 0; + $limitsql = $nbline; + } } + //print $limitsql.'-'.$page.'-'.$viewline; // Onglets @@ -467,7 +472,7 @@ if ($id > 0 || ! empty($ref)) // VAT $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='payment_vat'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."tva as t ON bu2.url_id = t.rowid"; - + // Salary payment $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_salary'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as sal ON bu3.url_id = sal.rowid"; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index f0fca0b90ff3ef2594e7cd5fc963a7bfe93ecd72..ae3038a6021887333b84b68b3bf239cc5d4e081e 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -1,6 +1,7 @@ <?php /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -22,6 +23,8 @@ <?php +global $user; + $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; @@ -47,16 +50,22 @@ foreach($linkedObjectBlock as $object) <tr <?php echo $GLOBALS['bc'][$var]; ?> ><td> <a href="<?php echo DOL_URL_ROOT.'/compta/facture.php?facid='.$object->id ?>"><?php echo img_object($langs->trans("ShowBill"),"bill").' '.$object->ref; ?></a></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td> - <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php + if ($user->rights->facture->lire) { + $total = $total + $object->total_ht; + echo price($object->total_ht); + } ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $object->total_ht; } ?> <tr class="liste_total"> <td align="left" colspan="2"><?php echo $langs->trans("TotalHT"); ?></td> - <td align="right"><?php echo price($total); ?></td> + <td align="right"><?php + if ($user->rights->facture->lire) { + echo price($total); + } ?></td> <td> </td> </tr> </table> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 53fa3b9c002ec4cdef71402baaa1d29508f91a12..36b4af841a86b99edb1045589e12e7b6ac602fc2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1089,7 +1089,6 @@ abstract class CommonObject } } - /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index fd7236505619e58da39d7027dd1ceffe7fc305bd..364afb921779760e82a4a08bb81253326f023ab2 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -21,6 +22,8 @@ <?php +global $user; + $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; @@ -47,17 +50,23 @@ foreach($linkedObjectBlock as $object) <a href="<?php echo DOL_URL_ROOT.'/expedition/fiche.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowShipping"),"sending").' '.$object->ref; ?></a></td> <td align="center"><?php echo dol_print_date($object->date_creation,'day'); ?></td> <td align="center"><?php echo dol_print_date($object->date_delivery,'day'); ?></td> - <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php + if ($user->rights->expedition->lire) { + $total = $total + $object->total_ht; + echo price($object->total_ht); + } ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $object->total_ht; } ?> <tr class="liste_total"> <td align="left" colspan="3"><?php echo $langs->trans('TotalHT'); ?></td> - <td align="right"><?php echo price($total); ?></td> + <td align="right"><?php + if ($user->rights->expedition->lire) { + echo price($total); + } ?></td> <td> </td> </tr> </table> diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 627b2de0d844c318d1dbd733ce9650705c9b9db8..0f70dc6bafc561c0c77e6ada25076d77bfc39b25 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -55,6 +56,18 @@ class PaiementFourn extends Paiement // 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 + /** + * Label of payment type + * @var string + */ + public $type_libelle; + + /** + * Code of Payment type + * @var string + */ + public $type_code; + /** * Constructor * @@ -74,7 +87,7 @@ class PaiementFourn extends Paiement function fetch($id) { $sql = 'SELECT p.rowid, p.datep as dp, p.amount, p.statut, p.fk_bank,'; - $sql.= ' c.libelle as paiement_type,'; + $sql.= ' c.code as paiement_code, c.libelle as paiement_type,'; $sql.= ' p.num_paiement, p.note, b.fk_account'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_paiement as c, '.MAIN_DB_PREFIX.'paiementfourn as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid '; @@ -95,6 +108,7 @@ class PaiementFourn extends Paiement $this->bank_line = $obj->fk_bank; $this->montant = $obj->amount; $this->note = $obj->note; + $this->type_code = $obj->paiement_code; $this->type_libelle = $obj->paiement_type; $this->statut = $obj->statut; $error = 1; diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index d1e209eb54b50e8b6afc6e86d92018f936b36b39..fc1942e0f615d90da110f0deb66829ed83b94d45 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -21,6 +22,8 @@ <?php +global $user; + $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; @@ -44,17 +47,23 @@ foreach($linkedObjectBlock as $object) <tr <?php echo $bc[$var]; ?> ><td> <a href="<?php echo DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowOrder"),"order").' '.$object->ref; ?></a></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td> - <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php + if ($user->rights->fournisseur->commande->lire) { + $total = $total + $object->total_ht; + echo price($object->total_ht); + } ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $object->total_ht; } ?> <tr class="liste_total"> <td align="left" colspan="2"><?php echo $langs->trans('TotalHT'); ?></td> - <td align="right"><?php echo price($total); ?></td> + <td align="right"><?php + if ($user->rights->fournisseur->commande->lire) { + echo price($total); + } ?></td> <td> </td> </tr> </table> diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index ab585cc4b1f25f525fe2c1587b47b8ea8e793b5d..c10fea8bb8aa6adb33f31780636f02878972ce08 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,6 @@ <?php /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@capnetworks.com> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -21,6 +22,8 @@ <?php +global $user; + $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; @@ -45,16 +48,22 @@ foreach($linkedObjectBlock as $object) <tr <?php echo $bc[$var]; ?> ><td> <a href="<?php echo DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$object->id ?>"><?php echo img_object($langs->trans("ShowBill"),"bill").' '.$object->ref; ?></a></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td> - <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php + if ($user->rights->fournisseur->facture->lire) { + $total = $total + $object->total_ht; + echo price($object->total_ht); + } ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $object->total_ht; } ?> <tr class="liste_total"> <td align="left" colspan="2"><?php echo $langs->trans("TotalHT"); ?></td> - <td align="right"><?php echo price($total); ?></td> + <td align="right"><?php + if ($user->rights->fournisseur->facture->lire) { + echo price($total); + } ?></td> <td> </td> </tr> </table> diff --git a/htdocs/fourn/paiement/fiche.php b/htdocs/fourn/paiement/fiche.php index 9a38e16f7f4dd276d7032623ca1cdfa470d8d3b9..0a2f3ad207fca142d3f37841cb1a44c6ce0aaee3 100644 --- a/htdocs/fourn/paiement/fiche.php +++ b/htdocs/fourn/paiement/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * * 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 @@ -180,7 +180,8 @@ if ($result > 0) print '</td></tr>'; // Payment mode - print '<tr><td valign="top" colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$object->type_libelle.'</td></tr>'; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle; + print '<tr><td valign="top" colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>'; // Payment numero print '<tr><td valign="top" colspan="2">'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c3b337c4a16ae366f12f65a266a113a04acf5322..ebe96b8b485f39ce1a28d9775c9438ea179f0b45 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4,10 +4,16 @@ * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2007-2011 Jean Heimburger <jean@tiaris.info> +<<<<<<< HEAD * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013-2014 Cedric GROSS <c.gross@kreiz-it.fr> * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> +======= + * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> + * Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr> + * Copyright (C) 2013-2014 Marcos García <marcosgdf@gmail.com> +>>>>>>> refs/remotes/origin/3.5 * * 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 @@ -602,7 +608,7 @@ class Product extends CommonObject foreach ($this->stock_warehouse as $idW => $ObjW) { $qty_batch = 0; - foreach ($ObjW->detail_batch as $detail) + foreach ($ObjW->detail_batch as $detail) { $qty_batch += $detail->qty; } @@ -615,12 +621,12 @@ class Product extends CommonObject $ObjBatch->qty = $ObjW->real - $qty_batch; $ObjBatch->fk_product_stock = $ObjW->id; if ($ObjBatch->create($user,1) < 0) - { + { $error++; $this->errors=$ObjBatch->errors; } } - } + } } // For automatic creation if ($this->barcode == -1) $this->barcode = $this->get_barcode($this,$this->barcode_type_code); @@ -994,6 +1000,62 @@ class Product extends CommonObject } } + /* + * Sets an accountancy code for a product. + * Also calls PRODUCT_MODIFY trigger when modified + * + * @param string $type It can be 'buy' or 'sell' + * @param string $value Accountancy code + * @return int <0 KO >0 OK + */ + public function setAccountancyCode($type, $value) + { + global $user, $langs, $conf; + + $this->db->begin(); + + if ($type == 'buy') { + $field = 'accountancy_code_buy'; + } elseif ($type == 'sell') { + $field = 'accountancy_code_sell'; + } else { + return -1; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET "; + $sql.= "$field = '".$this->db->escape($value)."'"; + $sql.= " WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::".__FUNCTION__." sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + + if ($resql) + { + // Call triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('PRODUCT_MODIFY',$this,$user,$langs,$conf); + if ($result < 0) + { + $this->errors=$interface->errors; + $this->db->rollback(); + return -1; + } + // End call triggers + + $this->$field = $value; + + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + /** * Load array this->multilangs * @@ -1426,8 +1488,8 @@ class Product extends CommonObject $this->entity = $obj->entity; $this->db->free($resql); - - + + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); @@ -1794,7 +1856,7 @@ class Product extends CommonObject return -1; } } - + /** * Charge tableau des stats contrat pour le produit/service * @@ -2977,7 +3039,7 @@ class Product extends CommonObject function load_virtual_stock() { global $conf; - + if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { $stock_commande_client=$stock_commande_fournisseur=0; @@ -3000,7 +3062,7 @@ class Product extends CommonObject $result=$this->load_stats_commande_fournisseur(0,'3'); if ($result < 0) dol_print_error($db,$this->error); $stock_commande_fournisseur=$this->stats_commande_fournisseur['qty']; - + $result=$this->load_stats_reception(0,'3'); if ($result < 0) dol_print_error($db,$this->error); $stock_reception_fournisseur=$this->stats_reception['qty']; diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index c1fc144e63dc677d439fd7415dd029b7e39ab713..a73d5817b3a4d116d7c595df93b5f9dac6c905d9 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -6,7 +6,7 @@ * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Auguria SARL <info@auguria.org> * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es> - * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2013-2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com> * Copyright (C) 2014 Cédric Gross <c.gross@kreiz-it.fr> @@ -145,20 +145,18 @@ if (empty($reshook)) } } - if ($action == 'setaccountancy_code_buy') - { - $result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy')); + if ($action == 'setaccountancy_code_buy') { + + $result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy')); if ($result < 0) setEventMessage(join(',',$object->errors), 'errors'); - else $object->accountancy_code_buy=GETPOST('accountancy_code_buy'); $action=""; } if ($action == 'setaccountancy_code_sell') { - $result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell')); - if ($result < 0) setEventMessage(join(',',$object->errors), 'errors'); - else $object->accountancy_code_sell=GETPOST('accountancy_code_sell'); - $action=""; + $result = $object->setAccountancyCode('sell', GETPOST('accountancy_code_sell')); + if ($result < 0) setEventMessage(join(',',$object->errors), 'errors'); + $action=""; } // Add a product or service @@ -221,7 +219,7 @@ if (empty($reshook)) $object->barcode_type_code = $stdobject->barcode_type_code; $object->barcode_type_coder = $stdobject->barcode_type_coder; $object->barcode_type_label = $stdobject->barcode_type_label; - + $object->description = dol_htmlcleanlastbr(GETPOST('desc')); $object->url = GETPOST('url'); $object->note = dol_htmlcleanlastbr(GETPOST('note')); @@ -335,7 +333,7 @@ if (empty($reshook)) $object->barcode_type_code = $stdobject->barcode_type_code; $object->barcode_type_coder = $stdobject->barcode_type_coder; $object->barcode_type_label = $stdobject->barcode_type_label; - + $object->accountancy_code_sell = GETPOST('accountancy_code_sell'); $object->accountancy_code_buy = GETPOST('accountancy_code_buy'); @@ -1329,7 +1327,7 @@ else if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2; if ($object->isservice()) $nblignes++; else $nblignes+=4; - + // Photo if ($showphoto || $showbarcode) { @@ -1339,7 +1337,7 @@ else if ($showbarcode) print $form->showbarcode($object); print '</td>'; } - + print '</tr>'; // Type @@ -1351,7 +1349,7 @@ else print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); print '</td></tr>'; } - + if ($showbarcode) { // Barcode type diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 0392b073dd45853562f7024c4579a397c56d8bda..a6ecf470d3847467d1a9daa8593515a87b919625 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -160,14 +160,7 @@ if (empty($reshook)) $object->forme_juridique_code = GETPOST('forme_juridique_code'); $object->effectif_id = GETPOST('effectif_id'); - if (GETPOST("private") == 1) - { - $object->typent_id = dol_getIdFromCode($db,'TE_PRIVATE','c_typent'); - } - else - { - $object->typent_id = GETPOST('typent_id'); - } + $object->typent_id = GETPOST('typent_id'); $object->client = GETPOST('client'); $object->fournisseur = GETPOST('fournisseur');