Merge remote-tracking branch 'Upstream/develop' into 5.0-p29

This commit is contained in:
aspangaro 2016-10-24 05:27:49 +02:00
commit d0544b0aea
84 changed files with 2605 additions and 2162 deletions

View File

@ -154,8 +154,10 @@ tag 729538 -moreinfo
##### Testing a package into unstable env
Check you have a mysql server available from another interface than "localhost".
Comment line in /etc/mysql/my.cnf if required and restart mysql
#bind-address = 127.0.0.1
Set line in /etc/mysql/my.cnf if required and restart mysql
[mysqld]
bind-address = *
Create a chroot called "unstable-amd64-sbuild".
Chroot env is stored into /srv/chroot directory.
@ -170,6 +172,8 @@ Puis pour se connecter et préparer l'environnement
> schroot -c name_of_chroot
> cat /etc/debian_chroot to check which debian branch we are into
> vi /usr/sbin/policy-rc.d and replace return code 101 (not allowed) into 0 (ok)
> apt-get update
> apt-get upgrade
> apt-get install links mysql-client
To test a package
@ -185,7 +189,7 @@ To test a package
If there is a problem launching apache, because port is already used, change it into your chroot install with
> vi /etc/apache2/ports.conf
Then restart.
Then you can call/test dolibarr with http://localhost:port/dolibarr/ (It can be also called from host).
Then you can call/test dolibarr with http://localhost:port/dolibarr/ . It can be also called FROM HOST (port must be a not used port on host).
@ -291,13 +295,18 @@ If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VER
* Edit orig.tar.gz file to remove
- debian
- htdocs/includes/ckeditor
- htdocs/includes/jszip
- htdocs/includes/jquery/plugins/datatables
- htdocs/includes/mike42
- htdocs/includes/phpexcel or htdocs/includes/phpoffice
- htdocs/includes/tcpdf or htdocs/includes/tecnickom
- htdocs/includes/swiftmailer
- htdocs/includes/restler/framework/Luracast/Restler/explorer
- htdocs/includes/tcpdf or htdocs/includes/tecnickcom
And rename file into
dolibarr-x.y.z+dfsgw.tgz
(x.y.z = version, w start from 1 and is increased for each new git-import-orig already done)
* Staying into git root directory, run
* Staying into projet gitted root directory, run
> git-import-orig -vv ../dolibarr-x.y.z+dfsgw.tgz --debian-branch=[master|jessie] --upstream-branch=[upstream|upstream-3.5.x]
and enter version when requested with format
x.y.z+dfsgw

View File

@ -16,7 +16,7 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm |
php5-mysql | php5-mysqli, php5-curl, php5-gd, php5-ldap,
# Required PHP libraries
php-pear, php-mail-mime,
# php-tcpdf, libfpdi-php,
# php-tcpdf,
# libfpdf-tpl-php, php-fpdf,
# libphp-adodb,
# libnusoap-php,

View File

@ -197,9 +197,6 @@ License: GPL-2+
On Debian systems, the full text of the GNU General Public
License version 2 can be found in the file
`/usr/share/common-licenses/GPL-2'.
Comment:
Those files are not shipped in the binary package as we
configure Dolibarr to use the library packaged in "libfpdi-php".
Files: htdocs/includes/geoip/*
Copyright: 2007 MaxMind LLC

View File

@ -147,7 +147,6 @@ case "$1" in
# File already exist. We add params not found.
#echo Add new params to overwrite path to use shared libraries/fonts
#grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "<?php \$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; ?>" >> $config
#grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "<?php \$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; ?>" >> $config
##grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "<?php \$dolibarr_lib_GEOIP_PATH=''; ?>" >> $config
#grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "<?php \$dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; ?>" >> $config
#grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "<?php \$dolibarr_lib_ODTPHP_PATHTOPCLZIP='/usr/share/php/libphp-pclzip'; ?>" >> $config

View File

@ -30,8 +30,6 @@ $force_install_lockinstall='444';
// - not removed from package (see rm in rules file),
// - declared into dependencies (see Depends in control file)
//$force_dolibarr_lib_TCPDF_PATH='';
//$force_dolibarr_lib_FPDF_PATH='/usr/share/php/fpdf';
//$force_dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi';
//$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';
//$force_dolibarr_lib_GEOIP_PATH='';
//$force_dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap';

View File

@ -79,7 +79,6 @@ override_dh_install:
# clean from all PHP embedded libraries (we use package dependencies instead)
# rm -fr htdocs/includes/adodbtime
# rm -fr htdocs/includes/fpdfi
# rm -fr htdocs/includes/geoip
# rm -fr htdocs/includes/nusoap
# rm -fr htdocs/includes/odtphp/zip/pclzip

View File

@ -296,7 +296,7 @@ if ($resql)
$moreforfilter = '';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escpae_htmltag($search_myfield).'">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';
$parameters=array();

View File

@ -259,10 +259,10 @@ if ($result)
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
print "</tr>\n";
print '<tr ' . $bc[false] . '><td width="25%"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
print '<tr ' . $bc[false] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductSellDesc'));
print "</td></tr>\n";
print '<tr ' . $bc[true] . '><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
print '<tr ' . $bc[true] . '><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductBuyDesc')) . "</td></tr>\n";
print "</table>\n";
@ -284,7 +284,7 @@ if ($result)
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
/*
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print_liste_field_titre($langs->trans("Accountancy_code_buy"));
@ -301,7 +301,7 @@ if ($result)
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
print '<td class="liste_titre">&nbsp;</td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre">&nbsp;</td>';
print '<td align="right" class="liste_titre">';
$searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1);
print $searchpitco;
@ -340,23 +340,33 @@ if ($result)
print '<tr'. $bc[$var].'>';
print "</tr>";
print '<tr'. $bc[$var].'>';
print '<tr '. $bc[$var].'>';
// Ref produit as link
$product_static->ref = $obj->ref;
$product_static->id = $obj->rowid;
$product_static->type = $obj->type;
$product_static->label = $obj->label;
$product_static->description = $obj->description;
print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1);
else
print '-&nbsp;';
print '</td>';
print '<td align="left">' . dol_trunc($obj->label, 24) . '</td>';
// TODO ADJUST DESCRIPTION SIZE
// print '<td align="left">' . $obj->description . '</td>';
// TODO: we shoul set a user defined value to adjust user square / wide screen size
$trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64;
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
print '<td align="left">'.$obj->label.'</td>';
if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
{
// TODO ADJUST DESCRIPTION SIZE
// print '<td align="left">' . $obj->description . '</td>';
// TODO: we shoul set a user defined value to adjust user square / wide screen size
$trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64;
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
}
// Accounting account buy
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {

View File

@ -273,7 +273,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_country" size="5" value="' . $search_country . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_tavintra" size="5" value="' . $search_tavintra . '"></td>';

View File

@ -342,12 +342,15 @@ if ($result) {
print price($objp->tva_tx_line);
print '</td>';
// Accounting account suggested
print '<td align="center" style="' . $code_sell_p_notset . '">';
if ($objp->code_sell_l == $objp->code_sell_p) {
if ($objp->code_sell_l == $objp->code_sell_p) { // Test if there is a difference between code by default and code on product
if ($objp->code_sell_l > 0) print $objp->code_sell_l;
else print $langs->trans("Unknown");
} else {
print $langs->trans("Buy") . ' = ' . $objp->code_sell_l . '<br />' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p;
print $langs->trans("Default") . ' = ' . ($objp->code_sell_l > 0 ? $objp->code_sell_l : $langs->trans("Unknown"));
print '<br>';
print $langs->trans("Product") . ' = ' . ($objp->code_sell_p > 0 ? $objp->code_sell_p : $langs->trans("Unknown"));
}
print '</td>';

View File

@ -45,6 +45,7 @@ $langs->load("bills");
$langs->load("accountancy");
$langs->load("compta");
$langs->load("banks");
$langs->load("loans");
/*
* Actions
@ -72,29 +73,24 @@ print "<br>\n";
// STEPS
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("Pcg_version").'</strong>');
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").'</strong>');
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("Chartofaccounts").'</strong>');
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").'</strong>');
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>')."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>')."<br>\n";
print "<br>\n";
$step++;
$textlink = '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong>';
$textlink = '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink);
print "<br>\n";
print "<br>\n";
$step++;
$textlink='<strong>'.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink);
print "<br>\n";
print "<br>\n";
if (! empty($conf->tax->enabled))
{
$textlink = '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong>';
$textlink = '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong>';
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink);
print "<br>\n";
@ -107,17 +103,30 @@ if (! empty($conf->tax->enabled))
// htdocs/admin/salaries.php
print "<br>\n";
print "<br>\n";
}*/
if (! empty($conf->loan->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuLoanAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}
/*
if (! empty($conf->don->enabled))
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDonationAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}*/
$step++;
$textlink='<strong>'.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink);
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("ProductsBinding").'</strong>')."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '<strong>'.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'</strong>')."<br>\n";
print "<br>\n";
print "<br>\n";

View File

@ -241,7 +241,7 @@ if ($result) {
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder);
@ -254,7 +254,7 @@ if ($result) {
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
print '<td class="liste_titre" align="right"></td>';
print '<td class="liste_titre" align="right"></td>';

View File

@ -174,7 +174,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accounta
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND product_type <= 2";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='')";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy ='')";
// Add search filter like
if (strlen(trim($search_invoice))) {
$sql .= " AND (f.ref like '%" . $search_invoice . "%')";
@ -352,13 +352,15 @@ if ($result) {
print price($objp->tva_tx_line);
print '</td>';
// Accounting account suggested
print '<td align="center" style="' . $code_buy_p_notset . '">';
// if not same kind of product_type stored in product & facturedet we display both account and let user choose
if ($objp->code_buy_l == $objp->code_buy_p) {
if ($objp->code_buy_l > 0) print $objp->code_buy_l;
else print $langs->trans("Unknown");
} else { // This can happen if user has change type of product after creation of invoice
print 'lines=' . $objp->code_buy_l . '<br />product=' . $objp->code_buy_p;
if ($objp->code_buy_l == $objp->code_buy_p) { // Test if there is a difference between code by default and code on product
if ($objp->code_buy_l > 0) print $objp->code_buy_l;
else print $langs->trans("Unknown");
} else {
print $langs->trans("Default") . ' = ' . ($objp->code_buy_l > 0 ? $objp->code_buy_l : $langs->trans("Unknown"));
print '<br>';
print $langs->trans("Product") . ' = ' . ($objp->code_buy_p > 0 ? $objp->code_buy_p : $langs->trans("Unknown"));
}
print '</td>';

View File

@ -1048,10 +1048,6 @@ else
print '</script>'."\n";
}
$rowspan=15;
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
if (! empty($conf->societe->enabled)) $rowspan++;
print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
print '<input type="hidden" name="action" value="update" />';
@ -1064,7 +1060,7 @@ else
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
@ -1077,21 +1073,7 @@ else
$morphys["mor"] = $langs->trans("Morale");
print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
print "</td>";
// Photo
print '<td align="center" class="hideonsmartphone" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $form->showphoto('memberphoto',$object)."\n";
if ($caneditfieldmember)
{
if ($object->photo) print "<br>\n";
print '<table class="nobordernopadding">';
if ($object->photo) print '<tr><td align="center"><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
print '</table>';
}
print '</td>';
print "</td></tr>";
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
@ -1123,6 +1105,21 @@ else
print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.(isset($_POST["firstname"])?$_POST["firstname"]:$object->firstname).'"></td>';
print '</tr>';
// Photo
print '<tr><td>'.$langs->trans("Photo").'</td>';
print '<td class="hideonsmartphone" valign="middle">';
print $form->showphoto('memberphoto',$object)."\n";
if ($caneditfieldmember)
{
if ($object->photo) print "<br>\n";
print '<table class="nobordernopadding">';
if ($object->photo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
print '</table>';
}
print '</td></tr>';
// EMail
print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="email" size="40" value="'.(isset($_POST["email"])?$_POST["email"]:$object->email).'"></td></tr>';

View File

@ -33,17 +33,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class AdherentType extends CommonObject
{
public $table_element = 'adherent_type';
public $element = 'adherent_type';
public $table_element = 'adherent_type';
public $element = 'adherent_type';
var $id;
var $ref;
var $libelle;
var $subscription; // Subscription required
var $note;
var $vote; // Can vote
var $mail_valid; // mail sent during validation
var $statut;
/** @var string Label */
public $libelle;
/**
* @var bool
* @deprecated Use subscription
* @see subscription
*/
public $cotisation;
/**
* @var bool Subsription required
* @since 5.0
*/
public $subscription;
/** @var string Public note */
public $note;
/** @var bool Can vote*/
public $vote;
/** @var bool Email sent during validation */
public $mail_valid;
/**

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
*
* 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
@ -33,10 +34,14 @@ $langs->load('other');
if (! $user->admin) accessforbidden();
$dirstandard = "/core/menus/standard";
$dirsmartphone = "/core/menus/smartphone";
$dirmenu = array($dirstandard,$dirsmartphone);
$dirstandard = array();
$dirsmartphone = array();
$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']);
foreach($dirmenus as $dirmenu)
{
$dirstandard[]=$dirmenu.'standard';
$dirsmartphone[]=$dirmenu.'smartphone';
}
$action=GETPOST('action');
@ -244,7 +249,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
$db->query($sql);
$result=$db->query($sql);
if ($result == 0)
{
@ -331,7 +336,7 @@ if ($action == 'create')
// Handler
print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
print '<td>';
$formadmin->select_menu_families($menu_handler,'menu_handler',$dirmenu);
$formadmin->select_menu_families($menu_handler.(preg_match('/_menu/',$menu_handler)?'':'_menu'),'menu_handler',array_merge($dirstandard,$dirsmartphone));
print '</td>';
print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';

144
htdocs/admin/resource.php Normal file
View File

@ -0,0 +1,144 @@
<?php
/* Copyright (C) 2016 Florian HENRY <florian.henry@atm-consulting.fr>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/admin/resource.php
* \ingroup resource
* \brief Setup page to configure resource module
*/
require '../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
if (! empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php';
$langs->load("admin");
$langs->load("resource");
// Security check
if (!$user->admin)
accessforbidden();
$action = GETPOST('action', 'alpha');
/*
* Actions
*/
if ($action == 'updateoptions')
{
if (GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'))
{
if (dolibarr_set_const($db, "RESOURCE_USE_SEARCH_TO_SELECT", GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'), 'chaine', 0, '', $conf->entity))
{
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
}
/*
* View
*/
llxHeader('',$langs->trans('ResourceSetup'));
$form = new Form($db);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ResourceSetup'),$linkback,'title_setup');
$head=resource_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("ResourceSingular"), 0, 'action');
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateoptions">';
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
print '<td align="right" width="60">'.$langs->trans("Value").'</td>'."\n";
print '<td></td>';
// Utilisation formulaire Ajax sur choix produit
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td width="80%">'.$langs->trans("UseSearchToSelectResource").'</td>';
if (empty($conf->use_javascript_ajax))
{
print '<td class="nowrap" align="right" colspan="2">';
print $langs->trans("NotAvailableWhenAjaxDisabled");
print '</td>';
}
else
{
print '<td width="60" align="right">';
$arrval=array(
'0'=>$langs->trans("No"),
'1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')',
'2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')',
'3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')',
);
print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT",$arrval,$conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
print '</td>';
print '<td align="right">';
print '<input type="submit" class="button" name="RESOURCE_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
print '</td>';
}
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans('DisabledResourceLinkUser').'</td>';
print '<td>';
echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_USER');
print '</td>';
print '<td></td>';
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans('DisabledResourceLinkContact').'</td>';
print '<td>';
echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY');
print '</td>';
print '<td></td>';
print '</tr>';
print '</table>';
print '</form>';
//RESOURCE_HIDE_ADD_CONTACT_USER
//RESOURCE_HIDE_ADD_CONTACT_THIPARTY
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -0,0 +1,122 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/resource_extrafields.php
* \ingroup agenda
* \brief Page to setup extra fields of resource
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!$user->admin)
accessforbidden();
$langs->load("admin");
$langs->load("other");
$langs->load("resource");
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label=ExtraFields::$type2label;
$type2label=array('');
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
$action=GETPOST('action', 'alpha');
$attrname=GETPOST('attrname', 'alpha');
$elementtype='resource'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
$textobject=$langs->transnoentitiesnoconv("ResourceSingular");
llxHeader('',$langs->trans("ResourceSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ResourceSetup"),$linkback,'title_setup');
print "<br>\n";
$head=resource_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), 0, 'action');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/* ************************************************************************** */
/* */
/* Creation of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'create')
{
print "<br>";
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/* ************************************************************************** */
/* */
/* Edition of an optional field */
/* */
/* ************************************************************************** */
if ($action == 'edit' && ! empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
llxFooter();
$db->close();

View File

@ -27,6 +27,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$langs->load("admin");
@ -111,9 +112,15 @@ print '<br>';
// Explorer
print '<u>'.$langs->trans("ApiExporerIs").':</u><br>';
$url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer'))
{
$url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer';
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
}
else
{
print $langs->trans("NotAvailableWithThisDistribution");
}
llxFooter();
$db->close();

View File

@ -2083,8 +2083,26 @@ if ($action == 'create')
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Amount HT
print '<tr><td class="titlefield">' . $langs->trans('AmountHT') . '</td>';
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
print '<td class="nowrap">' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
@ -2112,24 +2130,6 @@ if ($action == 'create')
print '<td class="nowrap">' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
if (!empty($conf->multicurrency->enabled))
{
// Multicurrency Amount HT
print '<tr><td>' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Statut
//print '<tr><td height="10">' . $langs->trans('Status') . '</td><td align="left" colspan="2">' . $object->getLibStatut(4) . '</td></tr>';

View File

@ -2301,8 +2301,26 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Total HT
print '<tr><td class="titlefield">' . $langs->trans('AmountHT') . '</td>';
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>';
// Total VAT
@ -2323,24 +2341,6 @@ if ($action == 'create' && $user->rights->commande->creer)
// Total TTC
print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
if (!empty($conf->multicurrency->enabled))
{
// Multicurrency Amount HT
print '<tr><td>' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Statut
//print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>';

View File

@ -35,10 +35,12 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$langs->load('orders');
@ -153,7 +155,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
*/
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
$parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@ -203,6 +205,225 @@ if (empty($reshook))
}
if($massaction == 'confirm_createbills') {
$orders = GETPOST('toselect');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
$validate_invoices = GETPOST('valdate_invoices', 'int');
$TFact = array();
$TFactThird = array();
$nb_bills_created = 0;
$db->begin();
foreach($orders as $id_order) {
$cmd = new Commande($db);
if($cmd->fetch($id_order) <= 0) continue;
$object = new Facture($db);
if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // To use only one bill for a third
else {
$object->socid = $cmd->socid;
$object->type = Facture::TYPE_STANDARD;
$object->cond_reglement_id = $cmd->cond_reglement_id;
$object->mode_reglement_id = $cmd->mode_reglement_id;
$object->fk_project = $cmd->fk_project;
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture))
{
$datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
}
$object->date = $datefacture;
$object->origin = 'commande';
$object->origin_id = $id_order;
$res = $object->create($user);
if($res > 0) $nb_bills_created++;
}
if($object->id > 0) {
$db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
$sql.= "fk_source";
$sql.= ", sourcetype";
$sql.= ", fk_target";
$sql.= ", targettype";
$sql.= ") VALUES (";
$sql.= $id_order;
$sql.= ", '".$object->origin."'";
$sql.= ", ".$object->id;
$sql.= ", '".$object->element."'";
$sql.= ")";
if ($db->query($sql))
{
$db->commit();
}
else
{
$db->rollback();
}
$lines = $cmd->lines;
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
{
$cmd->fetch_lines();
$lines = $cmd->lines;
}
$fk_parent_line=0;
$num=count($lines);
for ($i=0;$i<$num;$i++)
{
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
if ($lines[$i]->subprice < 0)
{
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc=$object->socid;
$discount->amount_ht=abs($lines[$i]->total_ht);
$discount->amount_tva=abs($lines[$i]->total_tva);
$discount->amount_ttc=abs($lines[$i]->total_ttc);
$discount->tva_tx=$lines[$i]->tva_tx;
$discount->fk_user=$user->id;
$discount->description=$desc;
$discountid=$discount->create($user);
if ($discountid > 0)
{
$result=$object->insert_discount($discountid);
//$result=$discount->link_to_invoice($lineid,$id);
}
else
{
setEventMessages($discount->error, $discount->errors, 'errors');
$error++;
break;
}
}
else
{
// Positive line
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
// Date start
$date_start=false;
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
//Date end
$date_end=false;
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
// Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
{
$fk_parent_line = 0;
}
$result = $object->addline(
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$date_start,
$date_end,
0,
$lines[$i]->info_bits,
$lines[$i]->fk_remise_except,
'HT',
0,
$product_type,
$ii,
$lines[$i]->special_code,
$object->origin,
$lines[$i]->rowid,
$fk_parent_line,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$lines[$i]->label
);
if ($result > 0)
{
$lineid=$result;
}
else
{
$lineid=0;
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9)
{
$fk_parent_line = $result;
}
}
}
}
$cmd->classifyBilled($user);
if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object;
else $TFact[$object->id] = $object;
}
// Build doc with all invoices
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
$toselect = array();
if(!empty($validate_invoices)) {
$massaction = $action = 'builddoc';
foreach($TAllFact as &$object) {
$object->validate($user);
$toselect[] = $object->id; // For builddoc action
// Fac builddoc
$upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
$objectclass='Facture';
$objectlabel='Invoice';
$permtoread = $user->rights->facture->lire;
$permtodelete = $user->rights->facture->supprimer;
$uploaddir = $conf->facture->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
if (! $error)
{
$db->commit();
setEventMessage($langs->trans('BillCreated', $nb_bills_created));
}
else
{
$db->rollback();
$action='create';
$_GET["origin"]=$_POST["origin"];
$_GET["originid"]=$_POST["originid"];
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
}
/*
@ -403,6 +624,7 @@ if ($resql)
if ($search_total_ttc != '') $param.='&search_total_ttc='.$search_total_ttc;
if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($billed != '') $param.='&billed='.$billed;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
@ -416,8 +638,9 @@ if ($resql)
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);
if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
// Lines of title fields
@ -529,6 +752,46 @@ if ($resql)
dol_fiche_end();
}
elseif ($massaction == 'createbills')
{
//var_dump($_REQUEST);
print '<input type="hidden" name="massaction" value="confirm_createbills">';
print '<table class="border" width="100%" >';
print '<tr>';
print '<td>';
print $langs->trans('DateInvoice');
print '</td>';
print '<td>';
print $form->select_date('', '', '', '', '', '', 1, 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print $langs->trans('CreateOneBillByThird');
print '</td>';
print '<td>';
print $form->selectyesno('createbills_onebythird', '', 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print $langs->trans('ValidateInvoices');
print '</td>';
print '<td>';
print $form->selectyesno('valdate_invoices', 1, 1);
print '</td>';
print '</tr>';
print '</table>';
print '<br />';
print '<div class="center">';
print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
print '<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans('Cancel').'">';
print '</div>';
print '<br />';
}
if ($sall)
{
@ -1157,9 +1420,11 @@ if ($resql)
print '</table>'."\n";
print '<br />';
print '</form>'."\n";
print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>';
//print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>';
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{

View File

@ -1,978 +0,0 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* 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-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2011-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/bank/account.php
* \ingroup banque
* \brief List of details of bank transactions for an account
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("bills");
$langs->load("companies");
$langs->load("salaries");
$langs->load("loan");
$langs->load("donations");
$langs->load("trips");
$langs->load("members");
$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
$ref = GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
$fieldtype = (! empty($ref) ? 'ref' :'rowid');
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque',$fieldvalue,'bank_account&bank_account','','',$fieldtype);
$paiementtype=GETPOST('paiementtype','alpha',3);
$req_nb=GETPOST("req_nb",'',3);
$thirdparty=GETPOST("thirdparty",'',3);
$req_desc=GETPOST("req_desc",'',3);
$req_debit=GETPOST("req_debit",'',3);
$req_credit=GETPOST("req_credit",'',3);
$req_stdtmonth=GETPOST('req_stdtmonth', 'int');
$req_stdtday=GETPOST('req_stdtday', 'int');
$req_stdtyear=GETPOST('req_stdtyear', 'int');
$req_stdt = dol_mktime(0, 0, 0, $req_stdtmonth, $req_stdtday, $req_stdtyear);
$req_enddtmonth=GETPOST('req_enddtmonth', 'int');
$req_enddtday=GETPOST('req_enddtday', 'int');
$req_enddtyear=GETPOST('req_enddtyear', 'int');
$req_enddt = dol_mktime(23, 59, 59, $req_enddtmonth, $req_enddtday, $req_enddtyear);
$search_reconciled = GETPOST('search_reconciled');
$vline=GETPOST("vline");
$page=GETPOST('page','int');
$negpage=GETPOST('negpage','int');
if ($negpage)
{
$page=GETPOST("nbpage") - $negpage;
if ($page > GETPOST("nbpage")) $page = GETPOST("nbpage");
}
$sortfield = "b.datev, b.datec, b.rowid";
$object = new Account($db);
/*
* Action
*/
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
$paiementtype="";
$req_nb="";
$thirdparty="";
$req_desc="";
$req_debit="";
$req_credit="";
$req_stdtmonth="";
$req_stdtday="";
$req_stdtyear="";
$req_stdt = "";
$req_enddtmonth="";
$req_enddtday="";
$req_enddtyear="";
$req_enddt = "";
$search_reconciled = '';
}
$dateop=-1;
if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banque->modifier)
{
$error = 0;
if (price2num($_POST["credit"]) > 0)
{
$amount = price2num($_POST["credit"]);
}
else
{
$amount = - price2num($_POST["debit"]);
}
$dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]);
$operation=$_POST["operation"];
$num_chq=$_POST["num_chq"];
$label=$_POST["label"];
$cat1=$_POST["cat1"];
if (! $dateop) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
}
if (! $operation) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors');
}
if (! $amount) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
}
if (! $error)
{
$object->fetch($id);
$insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
if ($insertid > 0)
{
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline");
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
$action='addline';
}
}
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier)
{
$accline=new AccountLine($db);
$result=$accline->fetch(GETPOST("rowid"));
$result=$accline->delete();
}
/*
* View
*/
$title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions");
$helpurl = "";
llxHeader('',$title,$helpurl);
$societestatic=new Societe($db);
$userstatic=new User($db);
$chargestatic=new ChargeSociales($db);
$loanstatic=new Loan($db);
$memberstatic=new Adherent($db);
$paymentstatic=new Paiement($db);
$paymentsupplierstatic=new PaiementFourn($db);
$paymentvatstatic=new TVA($db);
$paymentsalstatic=new PaymentSalary($db);
$donstatic=new Don($db);
$expensereportstatic=new ExpenseReport($db);
$bankstatic=new Account($db);
$banklinestatic=new AccountLine($db);
$form = new Form($db);
if ($id > 0 || ! empty($ref))
{
if ($vline)
{
$viewline = $vline;
}
else
{
$viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT;
}
$result=$object->fetch($id, $ref);
// Load bank groups
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
$bankcateg = new BankCateg($db);
$options = array();
foreach ($bankcateg->fetchAll() as $bankcategory) {
$options[$bankcategory->id] = $bankcategory->label;
}
// Definition de sql_rech et param
$param='';
$sql_rech='';
$mode_search = 0;
if ($req_nb)
{
$sql_rech.= " AND b.num_chq LIKE '%".$db->escape($req_nb)."%'";
$param.='&amp;req_nb='.urlencode($req_nb);
$mode_search = 1;
}
if ($req_desc)
{
$sql_rech.= " AND b.label LIKE '%".$db->escape($req_desc)."%'";
$param.='&amp;req_desc='.urlencode($req_desc);
$mode_search = 1;
}
if ($req_debit != '')
{
$sql_rech.=" AND b.amount = -".price2num($req_debit);
$param.='&amp;req_debit='.urlencode($req_debit);
$mode_search = 1;
}
if ($req_credit != '')
{
$sql_rech.=" AND b.amount = ".price2num($req_credit);
$param.='&amp;req_credit='.urlencode($req_credit);
$mode_search = 1;
}
if ($thirdparty)
{
$sql_rech.=" AND s.nom LIKE '%".$db->escape($thirdparty)."%'";
$param.='&amp;thirdparty='.urlencode($thirdparty);
$mode_search = 1;
}
if ($paiementtype)
{
$sql_rech.=" AND b.fk_type = '".$db->escape($paiementtype)."'";
$param.='&amp;paiementtype='.urlencode($paiementtype);
$mode_search = 1;
}
if ($req_stdt && $req_enddt)
{
$sql_rech.=" AND (b.datev BETWEEN '".$db->escape($db->idate($req_stdt))."' AND '".$db->escape($db->idate($req_enddt))."')";
$param.='&amp;req_stdtmonth='.$req_stdtmonth.'&amp;req_stdtyear='.$req_stdtyear.'&amp;req_stdtday='.$req_stdtday;
$param.='&amp;req_enddtmonth='.$req_enddtmonth.'&amp;req_enddtday='.$req_enddtday.'&amp;req_enddtyear='.$req_enddtyear;
$mode_search = 1;
}
elseif ($req_stdt)
{
$sql_rech.=" AND b.datev >= '".$db->escape($db->idate($req_stdt))."'";
$param.='&amp;req_stdtmonth='.$req_stdtmonth.'&amp;req_stdtyear='.$req_stdtyear.'&amp;req_stdtday='.$req_stdtday;
$mode_search = 1;
}
elseif ($req_enddt)
{
$sql_rech.=" AND b.datev <= '".$db->escape($db->idate($req_enddt))."'";
$param.='&amp;req_enddtmonth='.$req_enddtmonth.'&amp;req_enddtday='.$req_enddtday.'&amp;req_enddtyear='.$req_enddtyear;
$mode_search = 1;
}
if ($search_reconciled == 'reconciled') $sql_rech.=" AND num_releve IS NOT NULL";
if ($search_reconciled == 'notreconciled') $sql_rech.=" AND num_releve IS NULL";
$sql = "SELECT count(*) as total";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
if ($mode_search)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
}
$sql.= " WHERE b.fk_account = ".$object->id;
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= $sql_rech;
dol_syslog("account.php count transactions -", LOG_DEBUG);
$result=$db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$nbline = $obj->total;
$total_lines = $nbline;
$db->free($result);
}
else
{
dol_print_error($db);
}
//Total pages
$totalPages = ceil($total_lines/$viewline);
if ($totalPages == 0) {
$page = 0;
} 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
$head=bank_prepare_head($object);
dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_fiche_end();
/*
* Buttons actions
*/
if ($action != 'delete')
{
print '<div class="tabsAction">';
if ($action != 'addline')
{
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
{
if ($user->rights->banque->modifier) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&amp;id='.$object->id.'&amp;page='.$page.($vline?'&amp;vline='.$vline:'').'">'.$langs->trans("AddBankRecord").'</a>';
} else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
}
} else {
print '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
}
}
if ($object->canBeConciliated() > 0) {
// If not cash account and can be reconciliate
if ($user->rights->banque->consolidate) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline ? '&amp;vline='.$vline : '').'">'.$langs->trans("Conciliate").'</a>';
} else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
}
}
print '</div>';
}
print '<br>';
/**
* Search form
*/
$param.='&amp;account='.$object->id.'&amp;vline='.$vline;
// Confirmation delete
if ($action == 'delete')
{
$text=$langs->trans('ConfirmDeleteTransaction');
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;rowid='.GETPOST("rowid"),$langs->trans('DeleteTransaction'),$text,'confirm_delete');
}
// Define transaction list navigation string
print '<form action="'.$_SERVER["PHP_SELF"].'" name="newpage" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="vline" value="'.$vline.'">';
print '<input type="hidden" name="paiementtype" value="'.$paiementtype.'">';
print '<input type="hidden" name="req_nb" value="'.$req_nb.'">';
print '<input type="hidden" name="req_desc" value="'.$req_desc.'">';
print '<input type="hidden" name="req_debit" value="'.$req_debit.'">';
print '<input type="hidden" name="req_credit" value="'.$req_credit.'">';
print '<input type="hidden" name="thirdparty" value="'.$thirdparty.'">';
print '<input type="hidden" name="nbpage" value="'.$totalPages.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="req_stdtmonth" value="'.$req_stdtmonth.'">';
print '<input type="hidden" name="req_stdtyear" value="'.$req_stdtyear.'">';
print '<input type="hidden" name="req_stdtday" value="'.$req_stdtday.'">';
print '<input type="hidden" name="req_enddtmonth" value="'.$req_enddtmonth.'">';
print '<input type="hidden" name="req_enddtday" value="'.$req_enddtday.'">';
print '<input type="hidden" name="req_enddtyear" value="'.$req_enddtyear.'">';
$navig ='<div data-role="fieldcontain">';
if ($limitsql > $viewline) $navig.='<a href="account.php?'.$param.'&amp;page='.($page+1).'">'.img_previous().'</a>';
$navig.= '<label for="negpage">'.$langs->trans("Page")."</label> "; // ' Page ';
$navig.='<input type="text" name="negpage" id="negpage" size="1" class="flat" value="'.($totalPages-$page).'">';
$navig.='/'.$totalPages.' ';
if ($total_lines > $limitsql )
{
$navig.= '<a href="'.$_SERVER["PHP_SELF"].'?'.$param.'&amp;page='.($page-1).'">'.img_next().'</a>';
}
$navig.='</div>';
//var_dump($navig);
if ($action != 'addline' && $action != 'delete')
{
print '<div class="floatright">'.$navig.'</div>';
}
// Form to add a transaction with no invoice
if ($user->rights->banque->modifier && $action == 'addline')
{
print load_fiche_titre($langs->trans("AddBankRecordLong"),'','');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>&nbsp;</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Numero").'</td>';
print '<td colspan="2">'.$langs->trans("Description").'</td>';
print '<td align=right>'.$langs->trans("Debit").'</td>';
print '<td align=right>'.$langs->trans("Credit").'</td>';
print '<td colspan="2" align="center">&nbsp;</td>';
print '</tr>';
print '<tr '.$bc[false].'>';
print '<td class="nowrap" colspan="2">';
$form->select_date($dateop,'op',0,0,0,'transaction');
print '</td>';
print '<td class="nowrap">';
$form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1);
print '</td><td>';
print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq").'"></td>';
print '<td colspan="2">';
print '<input name="label" class="flat" type="text" size="24" value="'.GETPOST("label").'">';
if ($options) {
print '<br>'.$langs->trans("Rubrique").': ';
print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
}
print '</td>';
print '<td align=right><input name="debit" class="flat" type="text" size="4" value="'.GETPOST("debit").'"></td>';
print '<td align=right><input name="credit" class="flat" type="text" size="4" value="'.GETPOST("credit").'"></td>';
print '<td colspan="2" align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print '</table>';
print '</form>';
print '<br>';
}
/*
* Show list of bank transactions
*/
print '<form action="'.$_SERVER["PHP_SELF"].'?'.$param.'" name="search" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="search">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<table class="noborder" width="100%">';
// Ligne de titre tableau des ecritures
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print_liste_field_titre($langs->trans("Value"), '', 'b.datev, b.datec, b.rowid','',$param,'',$sortfield,$sortorder);
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Numero").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td align="right">'.$langs->trans("Debit").'</td>';
print '<td align="right">'.$langs->trans("Credit").'</td>';
print '<td align="right">'.$langs->trans("BankBalance").'</td>';
print '<td align="center">';
if ($object->canBeConciliated() > 0) {
print $langs->trans("AccountStatementShort");
} else {
print '&nbsp;';
}
print '</td>';
print '<td></td>';
print '</tr>';
$period_filter .= $langs->trans('From').'&nbsp;'.$form->select_date($req_stdt,'req_stdt',0,0,1,null,1,0,1);
$period_filter .= '&nbsp;';
$period_filter .= $langs->trans('to').'&nbsp;'.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,0,1);
print '<tr class="liste_titre">';
print '<td colspan="2">'.$period_filter.'</td>';
print '<td>';
//$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...)
$filtertype='';
$form->select_types_paiements($paiementtype,'paiementtype',$filtertype,2,1,1,8);
print '</td>';
print '<td><input type="text" class="flat" name="req_nb" value="'.$req_nb.'" size="2"></td>';
print '<td><input type="text" class="flat" name="req_desc" value="'.$req_desc.'" size="14"></td>';
print '<td><input type="text" class="flat" name="thirdparty" value="'.$thirdparty.'" size="14"></td>';
print '<td align="right"><input type="text" class="flat" name="req_debit" value="'.$req_debit.'" size="4"></td>';
print '<td align="right"><input type="text" class="flat" name="req_credit" value="'.$req_credit.'" size="4"></td>';
print '<td align="center">&nbsp;</td>';
print '<td align="center">';
$array=array('reconciled'=>$langs->trans("Reconciled"), 'notreconciled'=>$langs->trans("NotReconciled"));
print $form->selectarray('search_reconciled', $array, $search_reconciled, 1);
print '</td>';
print '<td class="liste_titre" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
print '</td>';
print "</tr>\n";
/*
* Another solution
* create temporary table solde type=heap select amount from llx_bank limit 100 ;
* select sum(amount) from solde ;
*/
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_bordereau,";
$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
if ($mode_search)
{
$sql.= ", s.rowid as socid, s.nom as thirdparty";
}
/*
if ($mode_search && ! empty($conf->adherent->enabled))
{
}
if ($mode_search && ! empty($conf->tax->enabled))
{
}
*/
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
if ($mode_search)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu1.url_id = s.rowid";
}
if ($mode_search && ! empty($conf->tax->enabled))
{
// 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";
}
if ($mode_search && ! empty($conf->adherent->enabled))
{
// TODO Mettre jointure sur adherent pour recherche sur un adherent
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='company'";
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu3.url_id = s.rowid";
}
$sql.= " WHERE b.fk_account=".$object->id;
$sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sql.= $sql_rech;
$sql.= $db->order($sortfield, "ASC"); // We add date of creation to have correct order when everything is done the same day
$sql.= $db->plimit($limitsql, 0);
dol_syslog("account.php get transactions -", LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
$now=dol_now();
$nows=dol_print_date($now,'%Y%m%d');
//$form->load_cache_types_paiements();
//$form->cache_types_paiements
$var=true;
$num = $db->num_rows($result);
$i = 0; $total = 0; $sep = -1; $total_deb=0; $total_cred=0;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$total = price2num($total + $objp->amount,'MT');
if ($i >= ($viewline * (($totalPages-$page)-1)))
{
$var=!$var;
// Is it a transaction in future ?
$dos=dol_print_date($db->jdate($objp->do),'%Y%m%d');
//print "dos=".$dos." nows=".$nows;
if ($dos < $nows) $sep=0; // 0 means there was at least one line before current date
if ($dos > $nows && ! $sep) // We have found a line in future and we already found on line before current date
{
$sep = 1 ;
print '<tr class="liste_total"><td colspan="8">';
print $langs->trans("CurrentBalance");
print '</td>';
print '<td align="right" class="nowrap"><b>'.price($total - $objp->amount).'</b></td>';
print "<td>&nbsp;</td>";
print '</tr>';
}
print '<tr '.$bc[$var].'>';
print '<td class="nowrap">'.dol_print_date($db->jdate($objp->do),"day")."</td>\n";
print '<td class="nowrap">'.dol_print_date($db->jdate($objp->dv),"day");
print "</td>\n";
// Payment type
print '<td class="nowrap">';
$label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type;
if ($objp->fk_type == 'SOLD') $label='&nbsp;';
if ($objp->fk_type == 'CHQ' && $objp->fk_bordereau > 0)
{
dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php');
$bordereaustatic = new RemiseCheque($db);
$bordereaustatic->id = $objp->fk_bordereau;
$label .= ' '.$bordereaustatic->getNomUrl(2);
}
print $label;
print "</td>\n";
// Num
print '<td class="nowrap">'.($objp->num_chq?$objp->num_chq:"")."</td>\n";
// Description
print '<td>';
// Show generic description
if (preg_match('/^\((.*)\)$/i',$objp->label,$reg))
{
// Generic description because between (). We show it after translating.
print $langs->trans($reg[1]);
}
else
{
print dol_trunc($objp->label,60);
}
// Add links after description
$links = $object->get_url($objp->rowid);
foreach($links as $key=>$val)
{
if ($links[$key]['type']=='payment')
{
$paymentstatic->id=$links[$key]['url_id'];
$paymentstatic->ref=$links[$key]['url_id'];
print ' '.$paymentstatic->getNomUrl(2);
}
elseif ($links[$key]['type']=='payment_supplier')
{
$paymentsupplierstatic->id=$links[$key]['url_id'];
$paymentsupplierstatic->ref=$links[$key]['url_id'];
print ' '.$paymentsupplierstatic->getNomUrl(2);
}
elseif ($links[$key]['type']=='payment_sc')
{
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
//print $langs->trans("SocialContributionPayment");
print '</a>';
}
elseif ($links[$key]['type']=='payment_vat')
{
$paymentvatstatic->id=$links[$key]['url_id'];
$paymentvatstatic->ref=$links[$key]['url_id'];
print ' '.$paymentvatstatic->getNomUrl(2);
}
elseif ($links[$key]['type']=='payment_salary')
{
$paymentsalstatic->id=$links[$key]['url_id'];
$paymentsalstatic->ref=$links[$key]['url_id'];
print ' '.$paymentsalstatic->getNomUrl(2);
}
elseif ($links[$key]['type']=='payment_loan')
{
print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
print '</a>';
}
elseif ($links[$key]['type']=='payment_donation')
{
print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">';
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
print '</a>';
}
elseif ($links[$key]['type']=='payment_expensereport')
{
print '<a href="'.DOL_URL_ROOT.'/expensereport/payment/card.php?id='.$links[$key]['url_id'].'">';
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
print '</a>';
}
elseif ($links[$key]['type']=='banktransfert')
{
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
if ($objp->amount > 0)
{
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
print ' ('.$langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1,'transactions');
print ' '.$langs->trans("toward").' ';
$bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref;
print $bankstatic->getNomUrl(1,'');
print ')';
}
else
{
$bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref;
print ' ('.$langs->trans("TransferFrom").' ';
print $bankstatic->getNomUrl(1,'');
print ' '.$langs->trans("toward").' ';
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
print $bankstatic->getNomUrl(1,'transactions');
print ')';
}
//var_dump($links);
}
elseif ($links[$key]['type']=='company')
{
}
elseif ($links[$key]['type']=='user')
{
}
elseif ($links[$key]['type']=='member')
{
}
elseif ($links[$key]['type']=='sc')
{
}
else
{
// Show link with label $links[$key]['label']
if (! empty($objp->label) && ! empty($links[$key]['label'])) print ' - ';
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg))
{
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1]=='paiement') $reg[1]='Payment';
print ' '.$langs->trans($reg[1]);
}
else
{
print ' '.$links[$key]['label'];
}
print '</a>';
}
}
print '</td>';
// Add third party column
print '<td>';
foreach($links as $key=>$val)
{
if ($links[$key]['type']=='company')
{
$societestatic->id=$links[$key]['url_id'];
$societestatic->name=$links[$key]['label'];
print $societestatic->getNomUrl(1,'',16);
}
else if ($links[$key]['type']=='user')
{
$userstatic->id=$links[$key]['url_id'];
$userstatic->lastname=$links[$key]['label'];
print $userstatic->getNomUrl(1,'');
}
else if ($links[$key]['type']=='sc')
{
// sc=old value
$chargestatic->id=$links[$key]['url_id'];
if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg))
{
if ($reg[1]=='socialcontribution') $reg[1]='SocialContribution';
$chargestatic->lib=$langs->trans($reg[1]);
}
else
{
$chargestatic->lib=$links[$key]['label'];
}
$chargestatic->ref=$chargestatic->lib;
print $chargestatic->getNomUrl(1,16);
}
else if ($links[$key]['type']=='loan')
{
$loanstatic->id=$links[$key]['url_id'];
if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg))
{
if ($reg[1]=='loan') $reg[1]='Loan';
$loanstatic->label=$langs->trans($reg[1]);
}
else
{
$loanstatic->label=$links[$key]['label'];
}
$loanstatic->ref=$links[$key]['url_id'];
print $loanstatic->getLinkUrl(1,16);
}
else if ($links[$key]['type']=='member')
{
$memberstatic->id=$links[$key]['url_id'];
$memberstatic->ref=$links[$key]['label'];
print $memberstatic->getNomUrl(1,16,'card');
}
}
print '</td>';
// Amount
if ($objp->amount < 0)
{
print '<td align="right" class="nowrap">'.price($objp->amount * -1).'</td><td>&nbsp;</td>'."\n";
$total_deb +=$objp->amount;
}
else
{
print '<td>&nbsp;</td><td align="right" class="nowrap">&nbsp;'.price($objp->amount).'</td>'."\n";
$total_cred +=$objp->amount;
}
// Balance
if (! $mode_search)
{
if ($total >= 0)
{
print '<td align="right" class="nowrap">&nbsp;'.price($total).'</td>';
}
else
{
print '<td align="right" class="error nowrap">&nbsp;'.price($total).'</td>';
}
}
else
{
print '<td align="right">-</td>';
}
// Transaction reconciliated or edit link
if ($objp->rappro && $object->canBeConciliated() > 0) // If line not conciliated and account can be conciliated
{
print '<td align="center" class="nowrap">';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_edit();
print '</a>';
print "&nbsp; ";
print '<a href="releve.php?num='.$objp->num_releve.'&amp;account='.$object->id.'">'.$objp->num_releve.'</a>';
print "</td>";
}
else
{
print '<td align="center">';
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_edit();
print '</a>';
}
else
{
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_view();
print '</a>';
}
if ($object->canBeConciliated() > 0 && empty($objp->rappro))
{
if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay))
{
print ' '.img_warning($langs->trans("Late"));
}
}
print '&nbsp;';
if ($user->rights->banque->modifier)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&amp;rowid='.$objp->rowid.'&amp;id='.$object->id.'&amp;page='.$page.'">';
print img_delete();
print '</a>';
}
print '</td>';
}
print '<td></td>';
print "</tr>";
}
$i++;
}
// Show total
if ($page == 0 && ! $mode_search)
{
//Real account situation
print '<tr class="liste_total"><td align="left" colspan="8">';
if ($sep > 0) print '&nbsp;'; // If we had at least one line in future
else print $langs->trans("CurrentBalance");
print ' '.$object->currency_code.'</td>';
print '<td align="right" class="nowrap"><b>'.price($total).'</b></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';
} else {
// Only total according row displays
print '<tr class="liste_total"><td align="left" colspan="6">';
if ($sep > 0) print '&nbsp;'; // If we had at least one line in future
else print $langs->trans("Total");
print ' '.$object->currency_code.'</td>';
print '<td align="right" class="nowrap"><b>'.price($total_deb*-1).'</b></td>';
print '<td align="right" class="nowrap"><b>'.price($total_cred).'</b></td>';
print '<td align="right" class="nowrap"><b>'.price($total_cred-($total_deb*-1)).'</b></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';
}
$db->free($result);
}
else
{
dol_print_error($db);
}
print "</table>";
print "</form>\n";
print '<br>';
}
else
{
print $langs->trans("ErrorBankAccountNotFound");
}
llxFooter();
$db->close();

View File

@ -147,7 +147,7 @@ if (!empty($id))
{
if (! preg_match('/,/', $id))
{
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
}
else
{

View File

@ -21,7 +21,7 @@
*/
/**
* \file htdocs/compta/bank/search.php
* \file htdocs/compta/bank/bankentries.php
* \ingroup banque
* \brief List of bank transactions
*/
@ -29,6 +29,7 @@
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@ -48,10 +49,31 @@ $langs->load("bills");
$langs->load("categories");
$langs->load("companies");
$langs->load("margins");
$langs->load("salaries");
$langs->load("loan");
$langs->load("donations");
$langs->load("trips");
$langs->load("members");
$id = GETPOST('id','int');
$ref = GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
$cancel=GETPOST('cancel','alpha');
$confirm=GETPOST('confirm','alpha');
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque');
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));
$fieldtype = (! empty($ref) ? 'ref' :'rowid');
if ($fielvalue)
{
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque',$fieldvalue,'bank_account&bank_account','','',$fieldtype);
}
else
{
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'banque');
}
$search_ref=GETPOST('search_ref','alpha');
$description=GETPOST("description",'alpha');
@ -62,9 +84,13 @@ $account=GETPOST("account",'int');
$bid=GETPOST("bid","int");
$search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int'));
$search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int'));
$search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int'));
$search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int'));
$search_thirdparty=GETPOST("thirdparty",'alpha');
$search_req_nb=GETPOST("req_nb",'alpha');
$search_num_releve=GETPOST("search_num_releve",'alpha');
$num_releve=GETPOST("num_releve");
$cat=GETPOST("cat");
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
@ -77,12 +103,12 @@ if ($page == -1) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortorder) $sortorder='DESC';
if (! $sortfield) $sortfield='b.dateo';
if (! $sortorder) $sortorder='ASC';
if (! $sortfield) $sortfield='b.datev';
$mode_balance_ok=false;
//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected
if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && $account > 0)
if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && ($id > 0 || ! empty($ref)))
{
$sortfield = 'b.datev, b.dateo, b.rowid';
$mode_balance_ok = true;
@ -90,11 +116,20 @@ if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && $a
if (strtolower($sortorder) == 'desc') $mode_balance_ok = false;
$object = new Account($db);
if ($id > 0 || ! empty($ref))
{
$result=$object->fetch($id, $ref);
$account = $object->id; // Force the search field on id of account
}
// Initialize technical object to manage context to save list fields
$contextpage='banktransactionlist';
$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id);
//var_dump($contextpage);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array($contextpage));
$hookmanager->initHooks(array('banktransactionlist', $contextpage));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
@ -109,7 +144,7 @@ $arrayfields=array(
'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1),
'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500),
'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'position'=>1000),
'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || ! empty($ref))?0:1), 'position'=>1000),
'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600),
'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605),
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1000),
@ -128,7 +163,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
/*
* Actions
*/
*/
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
@ -143,17 +178,21 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
{
$search_dt_start='';
$search_dt_end='';
$description="";
$search_dv_start='';
$search_dv_end='';
$description="";
$type="";
$debit="";
$credit="";
$account="";
$bid="";
$search_ref="";
$search_req_nb='';
$search_thirdparty='';
$search_num_releve='';
$thirdparty='';
$account="";
if ($id > 0 || ! empty($ref)) $account=$object->id;
}
if (empty($reshook))
@ -166,6 +205,120 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
// Conciliation
if (GETPOST('confirm_reconcile') && $user->rights->banque->consolidate)
{
$error=0;
// Definition, nettoyage parametres
$num_releve=trim(GETPOST("num_releve"));
if ($num_releve)
{
$bankline=new AccountLine($db);
if (isset($_POST['rowid']) && is_array($_POST['rowid']))
{
foreach($_POST['rowid'] as $row)
{
if ($row > 0)
{
$result=$bankline->fetch($row);
$bankline->num_releve=$num_releve; //$_POST["num_releve"];
$result=$bankline->update_conciliation($user, GETPOST("cat"));
if ($result < 0)
{
setEventMessages($bankline->error, $bankline->errors, 'errors');
$error++;
break;
}
}
}
}
else
{
$error++;
$langs->load("errors");
setEventMessages($langs->trans("NoRecordSelected"), null, 'errors');
}
}
else
{
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors');
}
if (! $error)
{
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); // To avoid to submit twice and allow back
exit;
}
}
$dateop=-1;
if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier)
{
$error = 0;
if (price2num($_POST["addcredit"]) > 0)
{
$amount = price2num($_POST["addcredit"]);
}
else
{
$amount = - price2num($_POST["adddebit"]);
}
$dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]);
$operation=$_POST["operation"];
$num_chq=$_POST["num_chq"];
$label=$_POST["label"];
$cat1=$_POST["cat1"];
if (! $dateop) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
}
if (! $operation) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors');
}
if (! $amount) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
}
if (! $error)
{
$object->fetch($id);
$insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user);
if ($insertid > 0)
{
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
$action='addline';
}
}
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier)
{
$accline=new AccountLine($db);
$result=$accline->fetch(GETPOST("rowid"));
$result=$accline->delete($user);
}
/*
* View
@ -193,7 +346,102 @@ $banklinestatic=new AccountLine($db);
$now = dol_now();
llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param);
// Must be before button action
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($id > 0) $param.='&id='.urlencode($id);
if (!empty($ref)) $param.='&ref='.urlencode($ref);
if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref);
if (!empty($description)) $param.='&description='.urlencode($description);
if (!empty($type)) $param.='&type='.urlencode($type);
if (!empty($debit)) $param.='&debit='.$debit;
if (!empty($credit)) $param.='&credit='.$credit;
if (!empty($account)) $param.='&account='.$account;
if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve);
if (!empty($bid)) $param.='&bid='.$bid;
if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int');
if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int');
if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPOST('search_start_dvmonth', 'int') . '&search_start_dvday=' . GETPOST('search_start_dvday', 'int') . '&search_start_dvyear=' . GETPOST('search_start_dvyear', 'int');
if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int');
if ($search_req_nb) $param.='&amp;req_nb='.urlencode($search_req_nb);
if (GETPOST("thirdparty")) $param.='&amp;thirdparty='.urlencode(GETPOST("thirdparty"));
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
if ($id > 0 || ! empty($ref))
{
$title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions");
$helpurl = "";
llxHeader('',$title,$helpurl);
// Load bank groups
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
$bankcateg = new BankCateg($db);
$options = array();
foreach ($bankcateg->fetchAll() as $bankcategory) {
$options[$bankcategory->id] = $bankcategory->label;
}
// Bank card
$head=bank_prepare_head($object);
dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
dol_fiche_end();
/*
* Buttons actions
*/
if ($action != 'addline' && $action != 'reconcile')
{
print '<div class="tabsAction">';
if ($action != 'addline')
{
if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT))
{
if ($user->rights->banque->modifier) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=addline&page='.$page.$param.'">'.$langs->trans("AddBankRecord").'</a>';
} else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
}
} else {
print '<a class="butActionRefused" title="'.$langs->trans("FeatureDisabled").'" href="#">'.$langs->trans("AddBankRecord").'</a>';
}
}
if ($object->canBeConciliated() > 0) {
// If not cash account and can be reconciliate
if ($user->rights->banque->consolidate) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?action=reconcile&id='.$object->id.$param.'">'.$langs->trans("Conciliate").'</a>';
} else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
}
}
print '</div>';
}
}
else
{
llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param);
}
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq,";
$sql.= " b.fk_account, b.fk_type,";
@ -215,17 +463,20 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid";
$sql.= " WHERE b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
if ($search_ref) $sql.=natural_search("b.rowid", $search_ref);
if ($account > 0) $sql.=" AND b.fk_account = ".$account;
// Search period criteria
if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'";
if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'";
// Search period criteria
if (dol_strlen($search_dv_start)>0) $sql .= " AND b.datev >= '" . $db->idate($search_dv_start) . "'";
if (dol_strlen($search_dv_end)>0) $sql .= " AND b.datev <= '" . $db->idate($search_dv_end) . "'";
if ($search_ref) $sql.=natural_search("b.rowid", $search_ref);
if ($search_req_nb) $sql.= natural_search("b.num_chq", $search_req_nb);
if ($search_num_releve) $sql.= natural_search("b.num_releve", $search_num_releve);
if ($search_thirdparty) $sql.= natural_search("s.nom", $search_thirdparty);
if ($description) $sql.= natural_search("b.label", $description); // Warning some text are just translation keys, not translated strings
if ($bid) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid;
if (! empty($type)) $sql.= " AND b.fk_type = '".$db->escape($type)."' ";
// Search period criteria
if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'";
if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'";
// Search criteria amount
$debit = price2num(str_replace('-','',$debit));
$credit = price2num(str_replace('-','',$credit));
@ -252,6 +503,7 @@ $sql.=$hookmanager->resPrint;
$sql.= $db->order($sortfield,$sortorder);
$nbtotalofrecords = 0;
$nbtotalofpages = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
@ -259,9 +511,25 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$nbtotalofpages = ceil($nbtotalofrecords/$limit);
}
if (($id > 0 || ! empty($ref)) && GETPOST("page",'int') === '')
{
// We open a list of transaction of a dedicated account and no page was set by defaut
// We force on last page.
$page = ($nbtotalofpages - 1);
$offset = $limit * $page;
if ($page < 0) $page = 0;
}
if (! empty($search_ref)) $mode_balance_ok=false;
if (! empty($req_nb)) $mode_balance_ok=false;
if (! empty($type)) $mode_balance_ok=false;
if (! empty($debit)) $mode_balance_ok=false;
if (! empty($credit)) $mode_balance_ok=false;
if (! empty($thirdparty)) $mode_balance_ok=false;
$sql.= $db->plimit($limit+1,$offset);
dol_syslog('compta/bank/search.php::', LOG_DEBUG);
dol_syslog('compta/bank/bankentries.php', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
@ -270,30 +538,6 @@ if ($resql)
$arrayofselected=is_array($toselect)?$toselect:array();
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref);
if (!empty($description)) $param.='&description='.urlencode($description);
if (!empty($type)) $param.='&type='.urlencode($type);
if (!empty($debit)) $param.='&debit='.$debit;
if (!empty($credit)) $param.='&credit='.$credit;
if (!empty($account)) $param.='&account='.$account;
if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve);
if (!empty($bid)) $param.='&bid='.$bid;
if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int');
if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int');
if ($search_req_nb) $param.='&amp;req_nb='.urlencode($search_req_nb);
if (GETPOST("thirdparty")) $param.='&amp;thirdparty='.urlencode(GETPOST("thirdparty"));
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
// List of mass actions available
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
@ -303,17 +547,148 @@ if ($resql)
if ($massaction == 'presend') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
// Confirmation delete
if ($action == 'delete')
{
$text=$langs->trans('ConfirmDeleteTransaction');
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1);
}
// Lines of title fields
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="search_form">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="search">';
print '<input type="hidden" name="action" value="'.($action?$action:'search').'">';
print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="ref" value="'.$ref.'">';
if (! empty($_REQUEST['bid'])) print '<input type="hidden" name="bid" value="'.$_REQUEST["bid"].'">';
// Form to reconcile
if ($user->rights->banque->consolidate && $action == 'reconcile')
{
// print '<table class="noborder" width="100%">';
// print '<tr '.$bcnd[false].'>';
// print '<td>';
print '<div class="valignmiddle inline-block" style="padding-right: 20px;">';
print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):'').'" size="10">'; // The only default value is value we just entered
print '</div>';
if ($options) {
print $langs->trans("EventualyAddCategory").': ';
print Form::selectarray('cat', $options, GETPOST('cat'), 1);
}
print '<br>'.$langs->trans("ThenCheckLinesAndConciliate").' ';
print '<input class="button" name="confirm_reconcile" type="submit" value="'.$langs->trans("Conciliate").'">';
print ' '.$langs->trans("or").' ';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
// Show last bank statements
$nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
$liste="";
$sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE fk_account=".$id." AND num_releve IS NOT NULL";
$sql.= $db->order("num_releve","DESC");
$sql.= $db->plimit($nbmax+1);
print '<br><br>';
print $langs->trans("LastAccountStatements").' : ';
$resqlr=$db->query($sql);
if ($resqlr)
{
$numr=$db->num_rows($resqlr);
$i=0;
$last_ok=0;
while (($i < $numr) && ($i < $nbmax))
{
$objr = $db->fetch_object($resqlr);
if (! $last_ok) {
$last_releve = $objr->num_releve;
$last_ok=1;
}
$i++;
$liste='<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$acct->id.'&amp;num='.$objr->num_releve.'">'.$objr->num_releve.'</a> &nbsp; '.$liste;
}
if ($numr >= $nbmax) $liste="... &nbsp; ".$liste;
print $liste;
if ($numr <= 0) print '<b>'.$langs->trans("None").'</b>';
}
else
{
dol_print_error($db);
}
print '<br><br>';
// print '</td></tr></table>';
}
// Form to add a transaction with no invoice
if ($user->rights->banque->modifier && $action == 'addline')
{
print load_fiche_titre($langs->trans("AddBankRecordLong"),'','');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>&nbsp;</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td>'.$langs->trans("Numero").'</td>';
print '<td colspan="2">'.$langs->trans("Description").'</td>';
print '<td align=right>'.$langs->trans("Debit").'</td>';
print '<td align=right>'.$langs->trans("Credit").'</td>';
print '<td colspan="2" align="center">&nbsp;</td>';
print '</tr>';
print '<tr '.$bcnd[false].'>';
print '<td class="nowrap" colspan="2">';
$form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction');
print '</td>';
print '<td class="nowrap">';
$form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1);
print '</td><td>';
print '<input name="num_chq" class="flat" type="text" size="4" value="'.GETPOST("num_chq").'"></td>';
print '<td colspan="2">';
print '<input name="label" class="flat" type="text" size="24" value="'.GETPOST("label").'">';
if ($options) {
print '<br>'.$langs->trans("Rubrique").': ';
print Form::selectarray('cat1', $options, GETPOST('cat1'), 1);
}
print '</td>';
print '<td align="right"><input name="adddebit" class="flat" type="text" size="4" value="'.GETPOST("adddebit").'"></td>';
print '<td align="right"><input name="addcredit" class="flat" type="text" size="4" value="'.GETPOST("addcredit").'"></td>';
print '<td colspan="2" align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Add").'"><br>';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</td></tr>';
print '</table>';
print '<br>';
}
/// ajax adjust value date
print '
<script type="text/javascript">
$(function() {
$("a.ajax").each(function(){
var current = $(this);
current.click(function()
{
$.get("'.DOL_URL_ROOT.'/core/ajax/bankconciliate.php?"+current.attr("href").split("?")[1], function(data)
{
console.log(data)
current.parent().prev().replaceWith(data);
});
return false;
});
});
});
</script>
';
$i = 0;
// Title
@ -324,24 +699,38 @@ if ($resql)
$morehtml.='/'.$nbtotalofpages.' ';
$morehtml.='</div>';
$picto='title_bank';
if ($id > 0 || ! empty($ref)) $picto='';
if (GETPOST("bid"))
{
$result=$bankcateg->fetch(GETPOST("bid"));
print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit);
print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit);
}
else
{
print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit);
print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit);
}
// We can add page now to param
if ($page != '') $param.='&page='.urlencode($page);
$moreforfilter = '';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter .= $langs->trans('Period') . ' ('.$langs->trans('DateOperationShort').') : ';
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('DateStart') . ' ';
$moreforfilter .= $langs->trans('DateOperationShort').' : ';
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('From') . ' ';
$moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1).'</div>';
$moreforfilter .= ' - ';
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('DateEnd') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'</div>';
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('to') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'</div>';
$moreforfilter .= '</div>';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter .= $langs->trans('DateValueShort').' : ';
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('From') . ' ';
$moreforfilter .= $form->select_date($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 1).'</div>';
$moreforfilter .= ' - ';
$moreforfilter .= '<div class="nowrap inline-block">'.$langs->trans('to') . ' ' . $form->select_date($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 1).'</div>';
$moreforfilter .= '</div>';
$parameters=array();
@ -391,6 +780,7 @@ if ($resql)
$parameters=array('arrayfields'=>$arrayfields);
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print_liste_field_titre('', $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
@ -398,7 +788,7 @@ if ($resql)
if (! empty($arrayfields['b.rowid']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_ref" size="4" value="'.dol_escape_htmltag($search_ref).'">';
print '<input type="text" class="flat" name="search_ref" size="2" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
if (! empty($arrayfields['description']['checked']))
@ -433,7 +823,7 @@ if ($resql)
if (! empty($arrayfields['ba.ref']['checked']))
{
print '<td align="right">';
$form->select_comptes($account,'account',0,'',1);
$form->select_comptes($account,'account',0,'',1, ($id > 0 || ! empty($ref)?' disabled="disabled"':''));
print '</td>';
}
if (! empty($arrayfields['b.debit']['checked']))
@ -460,14 +850,18 @@ if ($resql)
// Numero statement
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_num_releve" value="'.dol_escape_htmltag($search_num_releve).'" size="3"></td>';
}
print '<td class="liste_titre" align="middle">';
print '<td class="liste_titre" align="middle">';
print '</td>';
print '<td class="liste_titre" align="middle">';
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpitco;
print '</td>';
print "</tr>\n";
// Loop on each record
$total = 0; // For balance
$balance = 0; // For balance
$balancecalculated = false;
// Loop on each record
$sign = 1;
$totalarray=array();
@ -475,7 +869,36 @@ if ($resql)
{
$objp = $db->fetch_object($resql);
$total = price2num($total + ($sign * $objp->amount),'MT');
// If we are in a situation where we need/can show balance, we calculate the start of balance
if (! $balancecalculated && ! empty($arrayfields['balance']['checked']) && $mode_balance_ok)
{
//Loop on each record
$sign = 1;
$i = 0;
$sqlforbalance='SELECT SUM(b.amount) as balance';
$sqlforbalance.= " FROM ";
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,";
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b";
$sqlforbalance.= " WHERE b.fk_account = ba.rowid";
$sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sqlforbalance.= " AND b.fk_account = ".$account;
$sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'";
$resqlforbalance = $db->query($sqlforbalance);
//print $sqlforbalance;
if ($resqlforbalance)
{
$objforbalance = $db->fetch_object($resqlforbalance);
if ($objforbalance)
{
$balance = $objforbalance->balance;
}
}
else dol_print_error($db);
$balancecalculated=true;
}
$balance = price2num($balance + ($sign * $objp->amount),'MT');
if (empty($cachebankaccount[$objp->bankid]))
{
@ -648,8 +1071,17 @@ if ($resql)
// Date value
if (! empty($arrayfields['b.datev']['checked']))
{
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->dv),"day")."</td>\n";
if (! $i) $totalarray['nbfield']++;
print '<td align="center" class="nowrap">';
print '<span id="datevalue_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->dv),"day")."</span>";
print '&nbsp;';
print '<span>';
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
print img_edit_remove() . "</a> ";
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
print img_edit_add() ."</a>";
print '</span>';
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Payment type
@ -664,7 +1096,7 @@ if ($resql)
}
// Num cheque
if (! empty($arrayfields['b.num_releve']['checked']))
if (! empty($arrayfields['b.num_chq']['checked']))
{
print '<td class="nowrap" align="center">'.($objp->num_chq?$objp->num_chq:"")."</td>\n";
if (! $i) $totalarray['nbfield']++;
@ -734,15 +1166,15 @@ if ($resql)
// Balance
if (! empty($arrayfields['balance']['checked']))
{
if ($mode_balance_ok)
if ($mode_balance_ok)
{
if ($total >= 0)
if ($balance >= 0)
{
print '<td align="right" class="nowrap">&nbsp;'.price($total).'</td>';
print '<td align="right" class="nowrap">&nbsp;'.price($balance).'</td>';
}
else
{
print '<td align="right" class="error nowrap">&nbsp;'.price($total).'</td>';
print '<td align="right" class="error nowrap">&nbsp;'.price($balance).'</td>';
}
}
else
@ -751,20 +1183,36 @@ if ($resql)
}
}
if (! empty($arrayfields['b.num_releve']['checked']))
{
print '<td class="nowrap" align="center">';
// Transaction reconciliated or edit link
if ($bankaccount->canBeConciliated() > 0)
{
if ($objp->rappro) // If line not conciliated and account can be conciliated
{
print '<a href="releve.php?num='.$objp->num_releve.'&amp;account='.$object->id.'">'.$objp->num_releve.'</a>';
}
else if ($action == 'reconcile')
{
print '<input class="flat" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(! empty($_POST['rowid'][$objp->rowid])?' checked':'').'>';
}
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action edit/delete
print '<td class="nowrap" align="center">';
// Transaction reconciliated or edit link
if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated
{
print '<td align="center" class="nowrap">';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
print img_edit();
print '</a>';
print "&nbsp; ";
print '<a href="releve.php?num='.$objp->num_releve.'&amp;account='.$object->id.'">'.$objp->num_releve.'</a>';
print "</td>";
}
else
{
print '<td align="center">';
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'&amp;page='.$page.'">';
@ -781,7 +1229,7 @@ if ($resql)
{
if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay))
{
print ' '.img_warning($langs->trans("Late"));
print ' '.img_warning($langs->trans("ReconciliationLate"));
}
}
print '&nbsp;';
@ -791,20 +1239,21 @@ if ($resql)
print img_delete();
print '</a>';
}
print '</td>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>";
$i++;

View File

@ -76,7 +76,7 @@ if ($result)
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr ".$bc[$var].">";
print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/search.php?bid=$objp->rowid\">$objp->label</a></td>";
print "<td><a href=\"".DOL_URL_ROOT."/compta/bank/bankentries.php?bid=$objp->rowid\">$objp->label</a></td>";
print '<td align="right">'.$objp->nombre.'</td>';
print '<td align="right">'.price(abs($objp->somme))."</td>";
print '<td align="right">'.price(abs(price2num($objp->somme / $objp->nombre,'MT')))."</td>";

View File

@ -580,7 +580,7 @@ else
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@ -649,12 +649,6 @@ else
print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
print '<td>'.$object->min_desired.'</td></tr>';
print '<tr><td>'.$langs->trans("Web").'</td><td>';
if ($object->url) print '<a href="'.$object->url.'" target="_gobank">';
print $object->url;
if ($object->url) print '</a>';
print "</td></tr>\n";
// Accountancy code
print '<tr class="liste_titre_add"><td class="titlefield">'.$langs->trans("AccountancyCode").'</td>';
print '<td>';

View File

@ -1234,7 +1234,7 @@ class Account extends CommonObject
}
else if ($mode == 'transactions')
{
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$this->id.$linkclose;
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$this->id.$linkclose;
$linkend='</a>';
}
else if ($mode == 'receipts')
@ -1535,7 +1535,7 @@ class AccountLine extends CommonObject
var $fk_user_rappro;
var $fk_type;
var $rappro; // Is it conciliated
var $num_releve; // If conciliated, what is bank receipt
var $num_releve; // If conciliated, what is bank statement
var $num_chq; // Num of cheque
var $bank_chq; // Bank of cheque
var $fk_bordereau; // Id of cheque receipt
@ -1805,8 +1805,20 @@ class AccountLine extends CommonObject
*/
function update_conciliation(User $user, $cat)
{
global $conf;
$this->db->begin();
// Check statement field
if (! empty($conf->global->BANK_STATEMENT_REGEX_RULE))
{
if (! preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve))
{
$this->errors[]=$langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE);
return -1;
}
}
$sql = "UPDATE ".MAIN_DB_PREFIX."bank SET";
$sql.= " rappro = 1";
$sql.= ", num_releve = '".$this->num_releve."'";

View File

@ -107,6 +107,8 @@ else
{
dol_print_error($db);
}
if (empty($min)) $min = dol_now - 3600 * 24;
$log="graph.php: min=".$min." max=".$max;
dol_syslog($log);
@ -769,7 +771,7 @@ if ($account)
if ($_GET["option"]!='all')
{
$morehtml='<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'&option=all'.$moreparam.'">'.$langs->trans("ShowAllAccounts").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1);
}
else
{

View File

@ -423,7 +423,7 @@ foreach ($accounts as $key=>$type)
print '</td>';
print '<td align="center">'.$acc->getLibStatut(2).'</td>';
print '<td align="right">';
print '<a href="account.php?account='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
print '<a href="'.DOL_URL_ROOT.'/compta/bankentries.php?id='.$acc->id.'">'.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'</a>';
print '</td>';
// Action column

View File

@ -271,7 +271,7 @@ if ($result)
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/search.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref")."</td>";

View File

@ -1,468 +0,0 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/bank/rappro.php
* \ingroup banque
* \brief Page to reconciliate bank transactions
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
$langs->load("banks");
$langs->load("categories");
$langs->load("bills");
if (! $user->rights->banque->consolidate) accessforbidden();
$action=GETPOST('action', 'alpha');
$id=GETPOST('account', 'int');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="dateo";
/*
* Actions
*/
// Conciliation
if ($action == 'rappro' && $user->rights->banque->consolidate)
{
$error=0;
// Definition, nettoyage parametres
$num_releve=trim($_POST["num_releve"]);
if ($num_releve)
{
$bankline=new AccountLine($db);
if (isset($_POST['rowid']) && is_array($_POST['rowid']))
{
foreach($_POST['rowid'] as $row)
{
if($row > 0)
{
$result=$bankline->fetch($row);
$bankline->num_releve=$num_releve; //$_POST["num_releve"];
$result=$bankline->update_conciliation($user,$_POST["cat"]);
if ($result < 0)
{
setEventMessages($bankline->error, $bankline->errors, 'errors');
$error++;
break;
}
}
}
}
}
else
{
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors');
}
if (! $error)
{
header('Location: '.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$id); // To avoid to submit twice and allow back
exit;
}
}
/*
* Action suppression ecriture
*/
if ($action == 'del')
{
$bankline=new AccountLine($db);
if ($bankline->fetch($_GET["rowid"]) > 0) {
$result = $bankline->delete($user);
if ($result < 0) {
dol_print_error($db, $bankline->error);
}
} else {
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
}
}
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
$bankcateg = new BankCateg($db);
$options = array();
foreach ($bankcateg->fetchAll() as $bankcategory) {
$options[$bankcategory->id] = $bankcategory->label;
}
/*
* View
*/
$form=new Form($db);
llxHeader();
$societestatic=new Societe($db);
$chargestatic=new ChargeSociales($db);
$memberstatic=new Adherent($db);
$paymentstatic=new Paiement($db);
$paymentsupplierstatic=new PaiementFourn($db);
$paymentvatstatic=new TVA($db);
$remisestatic = new RemiseCheque($db);
$acct = new Account($db);
$acct->fetch($id);
$now=dol_now();
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type";
$sql.= ", b.fk_bordereau";
$sql.= ", bc.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau';
$sql.= " WHERE rappro=0 AND fk_account=".$acct->id;
$sql.= " ORDER BY $sortfield $sortorder";
$sql.= " LIMIT 1000"; // Limit to avoid page overload
/// ajax adjust value date
print '
<script type="text/javascript">
$(function() {
$("a.ajax").each(function(){
var current = $(this);
current.click(function()
{
$.get("'.DOL_URL_ROOT.'/core/ajax/bankconciliate.php?"+current.attr("href").split("?")[1], function(data)
{
current.parent().prev().replaceWith(data);
});
return false;
});
});
});
</script>
';
$resql = $db->query($sql);
if ($resql)
{
$var=True;
$num = $db->num_rows($resql);
print load_fiche_titre($langs->trans("Reconciliation").': <a href="account.php?account='.$acct->id.'">'.$acct->label.'</a>', '', 'title_bank.png');
print '<br>';
// Show last bank receipts
$nbmax=15; // We accept to show last 15 receipts (so we can have more than one year)
$liste="";
$sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank";
$sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL";
$sql.= $db->order("num_releve","DESC");
$sql.= $db->plimit($nbmax+1);
print $langs->trans("LastAccountStatements").' : ';
$resqlr=$db->query($sql);
if ($resqlr)
{
$numr=$db->num_rows($resqlr);
$i=0;
$last_ok=0;
while (($i < $numr) && ($i < $nbmax))
{
$objr = $db->fetch_object($resqlr);
if (! $last_ok) {
$last_releve = $objr->num_releve;
$last_ok=1;
}
$i++;
$liste='<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?account='.$acct->id.'&amp;num='.$objr->num_releve.'">'.$objr->num_releve.'</a> &nbsp; '.$liste;
}
if ($numr >= $nbmax) $liste="... &nbsp; ".$liste;
print $liste;
if ($numr > 0) print '<br><br>';
else print '<b>'.$langs->trans("None").'</b><br><br>';
}
else
{
dol_print_error($db);
}
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?account='.$acct->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="rappro">';
print '<input type="hidden" name="account" value="'.$acct->id.'">';
print '<strong>'.$langs->trans("InputReceiptNumber").'</strong>: ';
print '<input class="flat" name="num_releve" type="text" value="'.(GETPOST('num_releve')?GETPOST('num_releve'):'').'" size="10">'; // The only default value is value we just entered
print '<br>';
if ($options) {
print $langs->trans("EventualyAddCategory").': ';
print Form::selectarray('cat', $options, GETPOST('cat'), 1);
print '<br>';
}
print '<br>'.$langs->trans("ThenCheckLinesAndConciliate").' "'.$langs->trans("Conciliate").'"<br>';
print '<br>';
$paramlist='';
$paramlist.="&account=".$acct->id;
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">'."\n";
print_liste_field_titre($langs->trans("DateOperationShort"),$_SERVER["PHP_SELF"],"b.dateo","",$paramlist,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateValueShort"),$_SERVER["PHP_SELF"],"b.datev","",$paramlist,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"b.fk_type","",$paramlist,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"b.label","",$paramlist,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Debit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Credit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder);
print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$paramlist,' width="80 align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ToConciliate"),$_SERVER["PHP_SELF"],"","",$paramlist,' align="center" width="80" ',$sortfield,$sortorder);
print "</tr>\n";
$i = 0;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr ".$bc[$var].">\n";
// print '<form method="post" action="rappro.php?account='.$_GET["account"].'">';
// print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
// print "<input type=\"hidden\" name=\"rowid\" value=\"".$objp->rowid."\">";
// Date op
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->do),"day").'</td>';
// Date value
if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate))
{
print '<td align="center" class="nowrap">'."\n";
print '<span id="datevalue_'.$objp->rowid.'">'.dol_print_date($db->jdate($objp->dv),"day")."</span>";
print '&nbsp;';
print '<span>';
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;account='.$acct->id.'&amp;rowid='.$objp->rowid.'">';
print img_edit_remove() . "</a> ";
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$acct->id.'&amp;rowid='.$objp->rowid.'">';
print img_edit_add() ."</a>";
print '</span>';
print '</td>';
}
else
{
print '<td align="center">';
print dol_print_date($db->jdate($objp->dv),"day");
print '</td>';
}
// Type + Number
$label=($langs->trans("PaymentType".$objp->type)!="PaymentType".$objp->type)?$langs->trans("PaymentType".$objp->type):$objp->type; // $objp->type is a code
if ($label=='SOLD') $label='';
$link='';
if ($objp->fk_bordereau>0) {
$remisestatic->id = $objp->fk_bordereau;
$remisestatic->ref = $objp->number;
$link = ' '.$remisestatic->getNomUrl(1);
}
print '<td class="nowrap">'.$label.($objp->num_chq?' '.$objp->num_chq:'').$link.'</td>';
// Description
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'">';
$reg=array();
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parentheses on tente recherche de traduction
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]);
else print $objp->label;
print '</a>';
/*
* Ajout les liens (societe, company...)
*/
$newline=1;
$links = $acct->get_url($objp->rowid);
foreach($links as $key=>$val)
{
if ($newline == 0) print ' - ';
else if ($newline == 1) print '<br>';
if ($links[$key]['type']=='payment') {
$paymentstatic->id=$links[$key]['url_id'];
print ' '.$paymentstatic->getNomUrl(2);
$newline=0;
}
elseif ($links[$key]['type']=='payment_supplier') {
$paymentsupplierstatic->id=$links[$key]['url_id'];
$paymentsupplierstatic->ref=$links[$key]['label'];
print ' '.$paymentsupplierstatic->getNomUrl(1);
$newline=0;
}
elseif ($links[$key]['type']=='company') {
$societestatic->id=$links[$key]['url_id'];
$societestatic->name=$links[$key]['label'];
print $societestatic->getNomUrl(1,'',24);
$newline=0;
}
else if ($links[$key]['type']=='sc') {
$chargestatic->id=$links[$key]['url_id'];
$chargestatic->ref=$links[$key]['url_id'];
$chargestatic->lib=$langs->trans("SocialContribution");
print ' '.$chargestatic->getNomUrl(1);
}
else if ($links[$key]['type']=='payment_sc')
{
// We don't show anything because there is 1 payment for 1 social contribution and we already show link to social contribution
/*print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowPayment'),'payment').' ';
print $langs->trans("SocialContributionPayment");
print '</a>';*/
$newline=2;
}
else if ($links[$key]['type']=='payment_vat')
{
$paymentvatstatic->id=$links[$key]['url_id'];
$paymentvatstatic->ref=$links[$key]['url_id'];
$paymentvatstatic->ref=$langs->trans("VATPayment");
print ' '.$paymentvatstatic->getNomUrl(1);
}
else if ($links[$key]['type']=='banktransfert') {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowTransaction'),'payment').' ';
print $langs->trans("TransactionOnTheOtherAccount");
print '</a>';
}
else if ($links[$key]['type']=='member') {
print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
print img_object($langs->trans('ShowMember'),'user').' ';
print $links[$key]['label'];
print '</a>';
}
else {
//print ' - ';
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg))
{
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1]=='paiement') $reg[1]='Payment';
print $langs->trans($reg[1]);
}
else
{
print $links[$key]['label'];
}
print '</a>';
$newline=0;
}
}
print '</td>';
if ($objp->amount < 0)
{
print "<td align=\"right\" nowrap>".price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
}
else
{
print "<td>&nbsp;</td><td align=\"right\" nowrap>".price($objp->amount)."</td>\n";
}
if ($objp->rappro)
{
// If line already reconciliated, we show receipt
print "<td align=\"center\" nowrap=\"nowrap\"><a href=\"releve.php?num=$objp->num_releve&amp;account=$acct->id\">$objp->num_releve</a></td>";
}
else
{
// If not already reconciliated
if ($user->rights->banque->modifier)
{
print '<td align="center" width="30" class="nowrap">';
print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&amp;account='.$acct->id.'&amp;orig_account='.$acct->id.'">';
print img_edit();
print '</a>&nbsp; ';
$now=dol_now();
if ($db->jdate($objp->do) <= $now) {
print '<a href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?action=del&amp;rowid='.$objp->rowid.'&amp;account='.$acct->id.'">';
print img_delete();
print '</a>';
}
else {
print "&nbsp;"; // We prevents the deletion because reconciliation can not be achieved until the date has elapsed and that writing appears well on the account.
}
print "</td>";
}
else
{
print "<td align=\"center\">&nbsp;</td>";
}
}
// Show checkbox for conciliation
if ($db->jdate($objp->do) <= $now)
{
print '<td align="center" class="nowrap">';
print '<input class="flat" name="rowid['.$objp->rowid.']" type="checkbox" value="'.$objp->rowid.'" size="1"'.(! empty($_POST['rowid'][$objp->rowid])?' checked':'').'>';
print "</td>";
}
else
{
print '<td align="left">';
print $langs->trans("FutureTransaction");
print '</td>';
}
print "</tr>\n";
$i++;
}
$db->free($resql);
print "</table><br>\n";
print '<div align="right"><input class="button" type="submit" value="'.$langs->trans("Conciliate").'"></div><br>';
print "</form>\n";
}
else
{
dol_print_error($db);
}
llxFooter();
$db->close();

View File

@ -21,7 +21,7 @@
/**
* \file htdocs/compta/bank/releve.php
* \ingroup banque
* \brief Page to show a bank receipt report
* \brief Page to show a bank statement report
*/
require('../../main.inc.php');
@ -126,30 +126,19 @@ if (empty($num))
$head=bank_prepare_head($object);
dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account');
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td>';
print '<td colspan="3">'.$object->label.'</td></tr>';
print '</table>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
dol_fiche_end();
print '<div class="tabsAction">';
if ($object->canBeConciliated() > 0) {
// If not cash account and can be reconciliate
if ($user->rights->banque->consolidate) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$object->id.($vline ? '&amp;vline='.$vline : '').'">'.$langs->trans("Conciliate").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?id='.$object->id.'">'.$langs->trans("Conciliate").'</a>';
} else {
print '<a class="butActionRefused" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
}
@ -286,7 +275,7 @@ else
$mesprevnext.='<div class="pagination"><ul>';
$mesprevnext.='<li class="pagination"><a data-role="button" data-icon="arrow-l" data-iconpos="left" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$num.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><</a></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext.='<li class="pagination"><span class="inactive">'.$langs->trans("AccountStatement")." ".$num.'</span></li>';
$mesprevnext.='<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$num.'</span></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext.='<li class="pagination"><a data-role="button" data-icon="arrow-r" data-iconpos="right" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$num.'&amp;ve='.$ve.'&amp;account='.$object->id.'">></a></li>';
$mesprevnext.='</ul></div>';
@ -297,7 +286,7 @@ else
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print '<table class="border" width="100%">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td align="center">'.$langs->trans("DateOperationShort").'</td>';
print '<td align="center">'.$langs->trans("DateValueShort").'</td>';
@ -341,12 +330,12 @@ else
$result = $db->query($sql);
if ($result)
{
$var=True;
$var=False;
$numrows = $db->num_rows($result);
$i = 0;
// Ligne Solde debut releve
print "<tr><td colspan=\"4\"><a href=\"releve.php?num=$num&amp;ve=1&amp;rel=$rel&amp;account=".$object->id."\">&nbsp;</a></td>";
print "<tr ".$bc[$var]."><td colspan=\"4\"><a href=\"releve.php?num=$num&amp;ve=1&amp;rel=$rel&amp;account=".$object->id."\">&nbsp;</a></td>";
print "<td align=\"right\" colspan=\"2\"><b>".$langs->trans("InitialBankBalance")." :</b></td><td align=\"right\"><b>".price($total)."</b></td><td>&nbsp;</td></tr>\n";
while ($i < $numrows)
@ -362,13 +351,14 @@ else
// Date de valeur
print '<td align="center" valign="center" class="nowrap">';
print '<a href="releve.php?action=dvprev&amp;num='.$num.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_previous().'</a> ';
print dol_print_date($db->jdate($objp->dv),"day") .' ';
print '<a href="releve.php?action=dvprev&amp;num='.$num.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_edit_remove() . "</a> ";
print '<a href="releve.php?action=dvnext&amp;num='.$num.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
print img_next().'</a>';
print img_edit_add() ."</a>";
print "</td>\n";
print '<a class="ajax" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;account='.$objp->bankid.'&amp;rowid='.$objp->rowid.'">';
// Type and num
if ($objp->fk_type == 'SOLD') {
$type_label='&nbsp;';

View File

@ -21,7 +21,7 @@
*/
/**
* \file htdocs/compta/bank/virement.php
* \file htdocs/compta/bank/transfer.php
* \ingroup banque
* \brief Page de saisie d'un virement
*/
@ -91,11 +91,11 @@ if ($action == 'add')
$result=0;
// By default, electronic transfert from bank to bank
$typefrom='PRE';
$typefrom='VIR';
$typeto='VIR';
if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH)
{
// This is transfert of change
// This is transfer of change
$typefrom='LIQ';
$typeto='LIQ';
}
@ -112,7 +112,7 @@ if ($action == 'add')
if (! $error)
{
$mesgs = $langs->trans("TransferFromToDone","<a href=\"account.php?account=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"account.php?account=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
$mesgs = $langs->trans("TransferFromToDone","<a href=\"bankentries.php?id=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"bankentries.php?id=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
setEventMessages($mesgs, null, 'mesgs');
$db->commit();
}
@ -157,7 +157,7 @@ print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'title_ban
print $langs->trans("TransferDesc");
print "<br><br>";
print "<form name='add' method=\"post\" action=\"virement.php\">";
print '<form name="add" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';

View File

@ -1054,9 +1054,10 @@ if (empty($reshook))
$langs->trans('Deposit'),
$amountdeposit, // subprice
1, // quantity
$lines[$i]->tva_tx, 0, // localtax1_tx
$lines[$i]->tva_tx, // vat rate
0, // localtax1_tx
0, // localtax2_tx
0, // fk_product
(empty($conf->global->INVOICE_PRODUCTID_DEPOSIT)?0:$conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product
0, // remise_percent
0, // date_start
0, // date_end
@ -3099,7 +3100,7 @@ else if ($id > 0 || ! empty($ref))
print '</td></tr>';
}
// Conditions de reglement
// Payment term
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort');
@ -3184,21 +3185,24 @@ else if ($id > 0 || ! empty($ref))
print '</td></tr>';
// Multicurrency rate
print '<tr>';
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print fieldLabel('CurrencyRate','multicurrency_tx');
print '</td>';
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
//if ($object->multicurrency_code != $conf->currency)
//{
print '<tr>';
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print fieldLabel('CurrencyRate','multicurrency_tx');
print '</td>';
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon))
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editmulticurrencyrate') {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code);
} else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
}
print '</td></tr>';
//}
}
// Bank Account
@ -3307,9 +3311,29 @@ else if ($id > 0 || ! empty($ref))
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Amount
print '<tr><td class="titlefield">' . $langs->trans('AmountHT') . '</td>';
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
print '<td class="nowrap">' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
// Vat
print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td colspan="3" class="nowrap">' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
print '</tr>';
@ -3355,24 +3379,6 @@ else if ($id > 0 || ! empty($ref))
// Total with tax
print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td class="nowrap">' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '</td></tr>';
if (!empty($conf->multicurrency->enabled))
{
// Multicurrency Amount HT
print '<tr><td>' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
print '</table>';
// List of payments

View File

@ -1058,7 +1058,8 @@ class Facture extends CommonInvoice
if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
$sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount,f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp';
$sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount';
$sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp';
$sql.= ', f.remise_percent, f.remise_absolue, f.remise';
$sql.= ', f.datef as df, f.date_pointoftax';
$sql.= ', f.date_lim_reglement as dlr';
@ -1204,7 +1205,7 @@ class Facture extends CommonInvoice
{
$this->lines=array();
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, ';
$sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
$sql.= ' l.situation_percent, l.fk_prev_id,';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
$sql.= ' l.rang, l.special_code,';
@ -1243,6 +1244,8 @@ class Facture extends CommonInvoice
$line->fk_product_type = $objp->fk_product_type; // Type of product
$line->qty = $objp->qty;
$line->subprice = $objp->subprice;
$line->vat_src_code = $objp->vat_src_code;
$line->tva_tx = $objp->tva_tx;
$line->localtax1_tx = $objp->localtax1_tx;
$line->localtax2_tx = $objp->localtax2_tx;
@ -2311,7 +2314,7 @@ class Facture extends CommonInvoice
* @param string $desc Description of line
* @param double $pu_ht Unit price without tax (> 0 even for credit note)
* @param double $qty Quantity
* @param double $txtva Force vat rate, -1 for auto
* @param double $txtva Force Vat rate, -1 for auto
* @param double $txlocaltax1 Local tax 1 rate (deprecated)
* @param double $txlocaltax2 Local tax 2 rate (deprecated)
* @param int $fk_product Id of predefined product/service
@ -2363,6 +2366,16 @@ class Facture extends CommonInvoice
if (empty($fk_prev_id)) $fk_prev_id = 'null';
if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
$pu_ht=price2num($pu_ht);
@ -2408,9 +2421,6 @@ class Facture extends CommonInvoice
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc);
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx);
$total_ht = $tabprice[0];
@ -2445,6 +2455,7 @@ class Facture extends CommonInvoice
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
@ -2659,11 +2670,14 @@ class Facture extends CommonInvoice
$this->line->label = $label;
$this->line->desc = $desc;
$this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->remise_percent = $remise_percent;
$this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
$this->line->date_start = $date_start;
@ -4315,7 +4329,7 @@ class FactureLigne extends CommonInvoiceLine
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet';
$sql.= ' (fk_facture, fk_parent_line, label, description, qty,';
$sql.= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,';
$sql.= ' date_start, date_end, fk_code_ventilation, ';
$sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,';
@ -4329,6 +4343,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " ".price2num($this->qty).",";
$sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").",";
$sql.= " ".price2num($this->tva_tx).",";
$sql.= " ".price2num($this->localtax1_tx).",";
$sql.= " ".price2num($this->localtax2_tx).",";
@ -4514,6 +4529,7 @@ class FactureLigne extends CommonInvoiceLine
$sql.= ",remise_percent=".price2num($this->remise_percent)."";
if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
else $sql.= ",fk_remise_except=null";
$sql.= ",vat_src_code = '".(empty($this->vat_src_code)?'':$this->vat_src_code)."'";
$sql.= ",tva_tx=".price2num($this->tva_tx)."";
$sql.= ",localtax1_tx=".price2num($this->localtax1_tx)."";
$sql.= ",localtax2_tx=".price2num($this->localtax2_tx)."";

View File

@ -461,24 +461,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<table class="border" width="100%">';
// Third party
print '<tr><td><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td colspan="2">'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
// Date payment
print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
$datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment);
$form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date);
print '</td>';
print '<td>'.$langs->trans('Comments').'</td></tr>';
$rowspan=5;
print '</td></tr>';
// Payment mode
print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
$form->select_types_paiements((GETPOST('paiementcode')?GETPOST('paiementcode'):$facture->mode_reglement_code),'paiementcode','',2);
print "</td>\n";
print '<td rowspan="'.$rowspan.'" valign="top">';
print '<textarea name="comment" wrap="soft" cols="60" rows="'.ROWS_4.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td>';
print '</tr>';
// Bank account
@ -493,7 +488,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
}
else
{
print '<td colspan="2">&nbsp;</td>';
print '<td>&nbsp;</td>';
}
print "</tr>\n";
@ -515,6 +510,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '</td>';
print '<td><input name="chqbank" size="30" type="text" value="'.GETPOST('chqbank').'"></td></tr>';
// Comments
print '<tr><td>'.$langs->trans('Comments').'</td>';
print '<td valign="top">';
print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.(empty($_POST['comment'])?'':$_POST['comment']).'</textarea></td></tr>';
print '</table>';
dol_fiche_end();
@ -633,7 +633,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print '<td align="center">'.dol_print_date($db->jdate($objp->df),'day')."</td>\n";
// Currency
print '<td align="center">'.$objp->multicurrency_code."</td>\n";
if (!empty($conf->multicurrency->enabled)) print '<td align="center">'.$objp->multicurrency_code."</td>\n";
// Multicurrency Price
if (!empty($conf->multicurrency->enabled))

View File

@ -191,7 +191,7 @@ if ($resql)
// Bank
print '<td>';
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
else print '&nbsp;';
print '</td>';

View File

@ -40,7 +40,7 @@ elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
$link = GETPOST('link', 'alpha');
if ($link)
{
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') {
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') {
$link = 'http://' . $link;
}
dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link);
@ -124,7 +124,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'a
if ($f)
{
$link->url = GETPOST('link', 'alpha');
if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://')
if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://')
{
$link->url = 'http://' . $link->url;
}

View File

@ -171,7 +171,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// Recipient was provided from combo list
if ($_POST['receiver'] == 'thirdparty') // Id of third party
{
$sendto = $thirdparty->email;
$sendto = $thirdparty->name.' <'.$thirdparty->email.'>';
$sendtoid = 0;
}
else // Id du contact
@ -189,7 +189,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// Recipient was provided from combo list
if ($_POST['receivercc'] == 'thirdparty') // Id of third party
{
$sendtocc = $thirdparty->email;
$sendtocc = $thirdparty->name.' <'.$thirdparty->email.'>';
}
else // Id du contact
{
@ -199,6 +199,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if (dol_strlen($sendto))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$langs->load("commercial");
$fromtype = GETPOST('fromtype');
@ -235,11 +237,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if ($action == 'send' || $action == 'relance')
{
if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
$actionmsg2=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
$actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1);
if ($message)
{
$actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto;
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
$actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message);
@ -300,7 +303,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
}
// Send mail
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid);
if ($mailfile->error)
{

View File

@ -690,7 +690,7 @@ class CMailFile
* @param string $stringtoencode String to encode
* @return string string encoded
*/
function encodetorfc2822($stringtoencode)
static function encodetorfc2822($stringtoencode)
{
global $conf;
return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?=';
@ -1220,15 +1220,17 @@ class CMailFile
/**
* Return a formatted address string for SMTP protocol
*
* @param string $address Example: 'John Doe <john@doe.com>, Alan Smith <alan@smith.com>' or 'john@doe.com, alan@smith.com'
* @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between "
* @param int $encode 1=Encode name to RFC2822
* @return string If format 0: '<john@doe.com>' or 'John Doe <john@doe.com>' or '=?UTF-8?B?Sm9obiBEb2U=?= <john@doe.com>'
* If format 1: '<john@doe.com>'
* If format 2: 'john@doe.com'
* If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>'
* @param string $address Example: 'John Doe <john@doe.com>, Alan Smith <alan@smith.com>' or 'john@doe.com, alan@smith.com'
* @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between "
* @param int $encode 0=No encode name, 1=Encode name to RFC2822
* @param int $maxnumberofemail 0=No limit. Otherwise, maximum number of emails returned ($address may contains several email separated with ','). Add '...' if there is more.
* @return string If format 0: '<john@doe.com>' or 'John Doe <john@doe.com>' or '=?UTF-8?B?Sm9obiBEb2U=?= <john@doe.com>'
* If format 1: '<john@doe.com>'
* If format 2: 'john@doe.com'
* If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>'
* If format 4: 'John Doe' or 'john@doe.com' if no label exists
*/
function getValidAddress($address,$format,$encode='')
static function getValidAddress($address,$format,$encode=0,$maxnumberofemail=0)
{
global $conf;
@ -1237,6 +1239,7 @@ class CMailFile
$arrayaddress=explode(',',$address);
// Boucle sur chaque composant de l'adresse
$i=0;
foreach($arrayaddress as $val)
{
if (preg_match('/^(.*)<(.*)>$/i',trim($val),$regs))
@ -1252,7 +1255,13 @@ class CMailFile
if ($email)
{
$i++;
$newemail='';
if ($format == 4)
{
$newemail = $name?$name:$email;
}
if ($format == 2)
{
$newemail=$email;
@ -1265,10 +1274,17 @@ class CMailFile
{
if (! empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)) $newemail='<'.$email.'>';
elseif (! $name) $newemail='<'.$email.'>';
else $newemail=($format==3?'"':'').($encode?$this->encodetorfc2822($name):$name).($format==3?'"':'').' <'.$email.'>';
else $newemail=($format==3?'"':'').($encode?self::encodetorfc2822($name):$name).($format==3?'"':'').' <'.$email.'>';
}
$ret=($ret ? $ret.',' : '').$newemail;
// Stop if we have too much records
if ($maxnumberofemail && $i >= $maxnumberofemail)
{
if (count($arrayaddress) > $maxnumberofemail) $ret.='...';
break;
}
}
}

View File

@ -522,7 +522,7 @@ abstract class CommonObject
}
if (! empty($this->url))
{
$out.=dol_print_url($this->url,'',0,1);
$out.=dol_print_url($this->url,'_goout',0,1);
$outdone++;
}
if (! empty($conf->skype->enabled))

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
@ -42,8 +42,8 @@ function bank_prepare_head(Account $object)
$head[$h][2] = 'bankname';
$h++;
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/account.php?id=" . $object->id;
$head[$h][1] = $langs->trans("Transactions");
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/bankentries.php?id=" . $object->id;
$head[$h][1] = $langs->trans("BankTransactions");
$head[$h][2] = 'journal';
$h++;

View File

@ -926,9 +926,10 @@ function dol_get_fiche_end($notab=0)
* @param int $nodbprefix Do not include DB prefix to forge table name
* @param string $morehtmlleft More html code to show before ref
* @param string $morehtmlright More html code to show before navigation arrows
* @param int $onlybanner Put this to 1, if the card will contains only a banner
* @return void
*/
function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlright='')
function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlright='', $onlybanner=0)
{
global $conf, $form, $user, $langs;
@ -943,7 +944,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if ($object->element == 'user') $modulepart='userphoto';
if ($object->element == 'product') $modulepart='product';
print '<div class="arearef heightref valignmiddle" width="100%">';
print '<div class="'.($onlybanner?'':'arearef ').'heightref valignmiddle" width="100%">';
if ($object->element == 'product')
{
$width=80; $cssclass='photoref';

View File

@ -81,8 +81,37 @@ function resource_prepare_head($object)
$head[$h][1] = $langs->trans('Info');
$head[$h][2] = 'info';
$h++;*/
complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove');
return $head;
}
function resource_admin_prepare_head() {
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/admin/resource.php';
$head[$h][1] = $langs->trans("ResourceSetup");
$head[$h][2] = 'general';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin');
$head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove');
return $head;
}

View File

@ -101,7 +101,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?leftmenu=product&amp;type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stock/productlot_list.php', 'LotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 6, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2806__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stock/productlot_list.php', 'LotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 6, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&amp;leftmenu=stats&amp;type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 7, __ENTITY__);
-- Product - Services
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&amp;type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__);
@ -156,10 +156,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled', __HANDLER__, 'left', 1401__+MAX_llx_menu__, 'commercial', '', 1400__+MAX_llx_menu__, '/contrat/card.php?&action=create&amp;leftmenu=contracts', 'NewContract', 1, 'contracts', '$user->rights->contrat->creer', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled', __HANDLER__, 'left', 1402__+MAX_llx_menu__, 'commercial', '', 1400__+MAX_llx_menu__, '/contrat/list.php?leftmenu=contracts', 'List', 1, 'contracts', '$user->rights->contrat->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled', __HANDLER__, 'left', 1403__+MAX_llx_menu__, 'commercial', '', 1400__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts', 'MenuServices', 1, 'contracts', '$user->rights->contrat->lire', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1404__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=0', 'MenuInactiveServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1405__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=4', 'MenuRunningServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1406__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=4&amp;filter=expired', 'MenuExpiredServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1407__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=5', 'MenuClosedServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1404__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=0', 'MenuInactiveServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1405__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=4', 'MenuRunningServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1406__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=4&amp;filter=expired', 'MenuExpiredServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1407__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&amp;mode=5', 'MenuClosedServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 3, __ENTITY__);
-- Commercial - Interventions
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->ficheinter->enabled', __HANDLER__, 'left', 1500__+MAX_llx_menu__, 'commercial', 'ficheinter', 5__+MAX_llx_menu__, '/fichinter/list.php?leftmenu=ficheinter', 'Interventions', 0, 'interventions', '$user->rights->ficheinter->lire', '', 2, 8, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->ficheinter->enabled', __HANDLER__, 'left', 1501__+MAX_llx_menu__, 'commercial', '', 1500__+MAX_llx_menu__, '/fichinter/card.php?action=create&amp;leftmenu=ficheinter', 'NewIntervention', 1, 'interventions', '$user->rights->ficheinter->creer', '', 2, 0, __ENTITY__);
@ -210,19 +210,22 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__);
-- Accounting Expert
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accounting', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__);
-- Setup
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2400__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 1, 'accountancy_admin', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2452__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2400__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 1, 'accountancy_admin', '$user->rights->accounting->chartofaccount', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2453__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2400__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 1, 'accountancy_admin', '$user->rights->accounting->chartofaccount', '', 0, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2400__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ProductsBinding', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__);
-- Binding
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'ventil_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?leftmenu=dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'ventil_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?leftmenu=dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
-- Journals
-- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'journal', 2400__+MAX_llx_menu__, '/accountancy/journal/index.php?leftmenu=journal', 'Journaux', 1, 'accountancy', '$user->rights->accounting->comptarapport->lire', '', 0, 7, __ENTITY__);
-- General Ledger
@ -265,9 +268,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled', __HANDLER__, 'left', 2600__+MAX_llx_menu__, 'accountancy', 'bank', 14__+MAX_llx_menu__, '/compta/bank/index.php?leftmenu=bank&amp;mainmenu=bank', 'MenuBankCash', 0, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2601__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/card.php?action=create&amp;leftmenu=bank', 'MenuNewFinancialAccount', 1, 'banks', '$user->rights->banque->configurer', '', 0, 0, __ENTITY__);
-- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2602__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/categ.php?leftmenu=bank', 'Rubriques', 1, 'categories', '$user->rights->banque->configurer', '', 0, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/search.php?leftmenu=bank', 'ListTransactions', 1, 'banks', '$user->rights->banque->lire', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/bankentries.php?leftmenu=bank', 'ListTransactions', 1, 'banks', '$user->rights->banque->lire', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2604__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/budget.php?leftmenu=bank', 'ListTransactionsByCategory', 1, 'banks', '$user->rights->banque->lire', '', 0, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2606__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/virement.php?leftmenu=bank', 'BankTransfers', 1, 'banks', '$user->rights->banque->transfer', '', 0, 5, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2606__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/transfer.php?leftmenu=bank', 'BankTransfers', 1, 'banks', '$user->rights->banque->transfer', '', 0, 5, __ENTITY__);
-- Account - Categories
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2650__+MAX_llx_menu__, 'accountancy', 'cat', 14__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&amp;type=5', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2651__+MAX_llx_menu__, 'accountancy', '', 2650__+MAX_llx_menu__, '/categories/card.php?action=create&amp;type=5', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__);

View File

@ -307,7 +307,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
$newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire);
if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
{
$newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
$newmenu->add('/compta/bank/bankentries.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
}
$i++;
}

View File

@ -942,14 +942,30 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/accountancy/index.php?leftmenu=accountancy",$langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
// Chart of account
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1);
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10);
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20);
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40);
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30);
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30);
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&amp;leftmenu=accountancy", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50);
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1);
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10);
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20);
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40);
if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled))
{
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30);
}
if (! empty($conf->tax->enabled))
{
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30);
}
if (! empty($conf->loan->enabled))
{
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/loan.php?mainmenu=accountancy&amp;leftmenu=accountancy_admin", $langs->trans("MenuLoanAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_loan', 45);
}
/* not required yet, already supported by default account
if (! empty($conf->don->enabled))
{
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&amp;leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47);
}*/
if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&amp;leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50);
// Binding
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&amp;mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&amp;leftmenu=accountancy_dispatch_customer",$langs->trans("ToBind"),2,$user->rights->accounting->bind->write);
@ -1073,10 +1089,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/compta/bank/card.php?action=create",$langs->trans("MenuNewFinancialAccount"),1,$user->rights->banque->configurer);
$newmenu->add("/compta/bank/index.php?leftmenu=bank&amp;mainmenu=bank",$langs->trans("List"),1,$user->rights->banque->lire, '', $mainmenu, 'bank');
$newmenu->add("/compta/bank/search.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire);
$newmenu->add("/compta/bank/bankentries.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire);
$newmenu->add("/compta/bank/budget.php",$langs->trans("ListTransactionsByCategory"),1,$user->rights->banque->lire);
$newmenu->add("/compta/bank/virement.php",$langs->trans("MenuBankInternalTransfer"),1,$user->rights->banque->transfer);
$newmenu->add("/compta/bank/transfer.php",$langs->trans("MenuBankInternalTransfer"),1,$user->rights->banque->transfer);
}
if (! empty($conf->categorie->enabled)) {
@ -1396,7 +1412,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire);
if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate
{
$newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
$newmenu->add('/compta/bank/bankentries.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate);
}
$i++;
}

View File

@ -48,7 +48,7 @@ class modResource extends DolibarrModules
// Use a free id here
// (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 63000;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'resource';
@ -109,7 +109,7 @@ class modResource extends DolibarrModules
// Config pages. Put here list of php pages
// stored into resource/admin directory, used to setup module.
//$this->config_page_url = array("admin_resource.php@resource");
$this->config_page_url = array("resource.php");
// Dependencies
// List of modules id that must be enabled if this module is enabled
@ -199,8 +199,8 @@ class modResource extends DolibarrModules
// Menus
//-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Add here list of permission defined by
// an id, a label, a boolean and two constant strings.
// Example:
@ -266,7 +266,7 @@ class modResource extends DolibarrModules
'target'=> '',
'user'=> 0
);
// Exports
$r = 1;

View File

@ -468,8 +468,8 @@ else
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'')));
print '<a href="'.$url.'" class="toolbarbutton" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
$relativeurl=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'')));
print '<a href="'.$relativeurl.'" class="toolbarbutton" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
print '<img id="refreshbutton" class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
print '</a>';

View File

@ -584,7 +584,7 @@ class FactureFournisseur extends CommonInvoice
*/
function fetch_lines()
{
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx';
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
@ -609,7 +609,7 @@ class FactureFournisseur extends CommonInvoice
$line = new SupplierInvoiceLine($this->db);
$line->id = $obj->rowid;
$line->rowid = $obj->rowid;
$line->rowid = $obj->rowid;
$line->description = $obj->description;
$line->product_ref = $obj->product_ref;
$line->ref = $obj->product_ref;
@ -618,27 +618,29 @@ class FactureFournisseur extends CommonInvoice
$line->label = $obj->label;
$line->product_desc = $obj->product_desc;
$line->subprice = $obj->pu_ht;
$line->pu_ht = $obj->pu_ht;
$line->pu_ht = $obj->pu_ht;
$line->pu_ttc = $obj->pu_ttc;
$line->vat_src_code = $obj->vat_src_code;
$line->tva_tx = $obj->tva_tx;
$line->localtax1_tx = $obj->localtax1_tx;
$line->localtax2_tx = $obj->localtax2_tx;
$line->qty = $obj->qty;
$line->remise_percent = $obj->remise_percent;
$line->remise_percent = $obj->remise_percent;
$line->tva = $obj->total_tva;
$line->total_ht = $obj->total_ht;
$line->total_tva = $obj->total_tva;
$line->total_tva = $obj->total_tva;
$line->total_localtax1 = $obj->total_localtax1;
$line->total_localtax2 = $obj->total_localtax2;
$line->total_ttc = $obj->total_ttc;
$line->total_ttc = $obj->total_ttc;
$line->fk_product = $obj->fk_product;
$line->product_type = $obj->product_type;
$line->product_label = $obj->label;
$line->info_bits = $obj->info_bits;
$line->fk_parent_line = $obj->fk_parent_line;
$line->product_label = $obj->label;
$line->info_bits = $obj->info_bits;
$line->fk_parent_line = $obj->fk_parent_line;
$line->special_code = $obj->special_code;
$line->rang = $obj->rang;
$line->fk_unit = $obj->fk_unit;
$line->fk_unit = $obj->fk_unit;
// Multicurrency
$line->fk_multicurrency = $obj->fk_multicurrency;
@ -1241,7 +1243,7 @@ class FactureFournisseur extends CommonInvoice
*
* @param string $desc Description de la ligne
* @param double $pu Prix unitaire (HT ou TTC selon price_base_type, > 0 even for credit note)
* @param double $txtva Taux de tva force, sinon -1
* @param double $txtva Force Vat rate to use, -1 for auto.
* @param double $txlocaltax1 LocalTax1 Rate
* @param double $txlocaltax2 LocalTax2 Rate
* @param double $qty Quantite
@ -1277,6 +1279,16 @@ class FactureFournisseur extends CommonInvoice
if (empty($txtva)) $txtva=0;
if (empty($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2)) $txlocaltax2=0;
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$remise_percent=price2num($remise_percent);
$qty=price2num($qty);
@ -1285,8 +1297,6 @@ class FactureFournisseur extends CommonInvoice
$txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txlocaltax2);
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc, $this->thirdparty);
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
@ -1311,6 +1321,8 @@ class FactureFournisseur extends CommonInvoice
//$this->line->label=$label; // deprecated
$this->line->desc=$desc;
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
$this->line->localtax2_tx=$txlocaltax2;
@ -1470,6 +1482,8 @@ class FactureFournisseur extends CommonInvoice
$line->pu_ttc = $pu_ttc;
$line->qty = $qty;
$line->remise_percent = $remise_percent;
$this->line->vat_src_code=$vat_src_code;
$line->tva_tx = $vatrate;
$line->localtax1_tx = $txlocaltax1;
$line->localtax2_tx = $txlocaltax2;
@ -2448,6 +2462,7 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql.= ", pu_ttc = ".price2num($this->pu_ttc);
$sql.= ", qty = ".price2num($this->qty);
$sql.= ", remise_percent = ".price2num($this->remise_percent);
$sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->vat_src_code)."'";
$sql.= ", tva_tx = ".price2num($this->tva_tx);
$sql.= ", localtax1_tx = ".price2num($this->localtax1_tx);
$sql.= ", localtax2_tx = ".price2num($this->localtax2_tx);
@ -2571,7 +2586,7 @@ class SupplierInvoiceLine extends CommonObjectLine
// Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' (fk_facture_fourn, fk_parent_line, label, description, qty,';
$sql.= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,';
$sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
$sql.= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit';
@ -2582,6 +2597,7 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " ".price2num($this->qty).",";
$sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").",";
$sql.= " ".price2num($this->tva_tx).",";
$sql.= " ".price2num($this->localtax1_tx).",";
$sql.= " ".price2num($this->localtax2_tx).",";
@ -2650,6 +2666,38 @@ class SupplierInvoiceLine extends CommonObjectLine
$this->db->rollback();
return -2;
}
}
}
}
/**
* Mise a jour de l'objet ligne de commande en base
*
* @return int <0 si ko, >0 si ok
*/
function update_total()
{
$this->db->begin();
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
$sql.= " total_ht='".price2num($this->total_ht)."'";
$sql.= ", tva='".price2num($this->total_tva)."'";
$sql.= ", total_localtax1='".price2num($this->total_localtax1)."'";
$sql.= ", total_localtax2='".price2num($this->total_localtax2)."'";
$sql.= ", total_ttc='".price2num($this->total_ttc)."'";
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -2;
}
}
}

View File

@ -521,9 +521,10 @@ class ProductFournisseur extends Product
*
* @param int $prodid Product id
* @param int $qty Minimum quantity
* @param int $socid get min price for specific supplier
* @return int <0 if KO, 0=Not found of no product id provided, >0 if OK
*/
function find_min_price_product_fournisseur($prodid, $qty=0)
function find_min_price_product_fournisseur($prodid, $qty=0, $socid=0)
{
global $conf;
@ -556,6 +557,7 @@ class ProductFournisseur extends Product
$sql.= " AND pfp.fk_soc = s.rowid";
$sql.= " AND s.status = 1"; // only enabled society
if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty;
if ($socid > 0) $sql.= ' AND pfp.fk_soc = '.$socid;
dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG);

View File

@ -1059,7 +1059,7 @@ if (empty($reshook))
$array_option = $lines[$i]->array_options;
}
$result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty);
$result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid);
if ($result>=0)
{
$tva_tx = $lines[$i]->tva_tx;

View File

@ -355,243 +355,425 @@ if (empty($reshook))
// Create
elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
{
$error=0;
if ($socid > 0) $object->socid = GETPOST('socid', 'int');
$datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']);
$datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
$db->begin();
if (GETPOST('socid','int')<1)
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')), null, 'errors');
$action='create';
$error++;
}
$error = 0;
if ($datefacture == '')
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
$error++;
}
if (! GETPOST('ref_supplier'))
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')), null, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
$error++;
}
// Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
// Fill array 'array_options' with data from add form
$datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']);
$datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
if (! $error)
{
$db->begin();
// Replacement invoice
if ($_POST['type'] == FactureFournisseur::TYPE_REPLACEMENT)
{
if ($datefacture == '')
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
$error++;
}
if (! ($_POST['fac_replacement'] > 0)) {
$error ++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors');
}
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) $error++;
if (! $error) {
// This is a replacement invoice
$result = $object->fetch($_POST['fac_replacement']);
$object->fetch_thirdparty();
$tmpproject = GETPOST('projectid', 'int');
$object->ref = $_POST['ref'];
$object->ref_supplier = $_POST['ref_supplier'];
$object->socid = $_POST['socid'];
$object->libelle = $_POST['label'];
$object->date = $datefacture;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
// Creation facture
$object->ref = $_POST['ref'];
$object->ref_supplier = $_POST['ref_supplier'];
$object->socid = $_POST['socid'];
$object->libelle = $_POST['label'];
$object->date = $datefacture;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
// Proprietes particulieres a facture de remplacement
$object->fk_facture_source = $_POST['fac_replacement'];
$object->type = FactureFournisseur::TYPE_REPLACEMENT;
// Auto calculation of date due if not filled by user
if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
$id = $object->createFromCurrent($user);
if ($id <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
// If creation from another object of another module
if (! $error && $_POST['origin'] && $_POST['originid'])
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $_POST['origin'];
/*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}*/
// Credit note invoice
if ($_POST['type'] == FactureFournisseur::TYPE_CREDIT_NOTE)
{
$sourceinvoice = GETPOST('fac_avoir');
if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
{
$error ++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors');
}
if (GETPOST('socid','int')<1)
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')), null, 'errors');
$action='create';
$error++;
}
if ($datefacture == '')
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
$error++;
}
if (! GETPOST('ref_supplier'))
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')), null, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
$error++;
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal'; $subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
if ($element == 'order_supplier') {
$element = 'fourn'; $subelement = 'fournisseur.commande';
}
if ($element == 'project')
{
$element = 'projet';
}
$object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid'];
if (! $error)
{
$tmpproject = GETPOST('projectid', 'int');
$id = $object->create($user);
// Creation facture
$object->ref = $_POST['ref'];
$object->ref_supplier = $_POST['ref_supplier'];
$object->socid = $_POST['socid'];
$object->libelle = $_POST['label'];
$object->date = $datefacture;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
// Add lines
if ($id > 0)
{
require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php';
$classname = ucfirst($subelement);
if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur';
$srcobject = new $classname($db);
// Proprietes particulieres a facture avoir
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
$object->type = FactureFournisseur::TYPE_CREDIT_NOTE;
$result=$srcobject->fetch($_POST['originid']);
if ($result > 0)
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines'))
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$id = $object->create($user);
$num=count($lines);
for ($i = 0; $i < $num; $i++)
{
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0)
{
$facture_source = new FactureFournisseur($db); // fetch origin object
if ($facture_source->fetch($object->fk_facture_source)>0)
{
$fk_parent_line = 0;
// Dates
// TODO mutualiser
$date_start=$lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
$date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
foreach($facture_source->lines as $line)
{
// Reset fk_parent_line for no child products and special product
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
$fk_parent_line = 0;
}
// FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example.
$result = $object->addline(
$desc,
$lines[$i]->subprice,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$lines[$i]->qty,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$date_start,
$date_end,
0,
$lines[$i]->info_bits,
'HT',
$product_type,
$lines[$i]->rang,
0,
$lines[$i]->array_options,
$lines[$i]->fk_unit,
$lines[$i]->id
);
$line->fk_facture = $object->id;
$line->fk_parent_line = $fk_parent_line;
if ($result < 0)
{
$error++;
break;
}
}
$line->subprice =-$line->subprice; // invert price for object
$line->pa_ht = -$line->pa_ht;
$line->total_ht=-$line->total_ht;
$line->total_tva=-$line->total_tva;
$line->total_ttc=-$line->total_ttc;
$line->total_localtax1=-$line->total_localtax1;
$line->total_localtax2=-$line->total_localtax2;
// Now reload line
$object->fetch_lines();
}
else
{
$error++;
}
}
else
{
$error++;
}
}
else if (! $error)
{
$id = $object->create($user);
if ($id < 0)
{
$error++;
}
$result = $line->insert();
if (! $error)
{
// If some invoice's lines already known
for ($i = 1 ; $i < 9 ; $i++)
{
$label = $_POST['label'.$i];
$amountht = price2num($_POST['amount'.$i]);
$amountttc = price2num($_POST['amountttc'.$i]);
$tauxtva = price2num($_POST['tauxtva'.$i]);
$qty = $_POST['qty'.$i];
$fk_product = $_POST['fk_product'.$i];
if ($label)
{
if ($amountht)
{
$price_base='HT'; $amount=$amountht;
}
else
{
$price_base='TTC'; $amount=$amountttc;
}
$atleastoneline=1;
$object->lines[] = $line; // insert new line in current object
$product=new Product($db);
$product->fetch($_POST['idprod'.$i]);
// Defined the new fk_parent_line
if ($result > 0 && $line->product_type == 9) {
$fk_parent_line = $result;
}
}
$ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base, $_POST['rang'.$i], 1);
if ($ret < 0) $error++;
}
}
}
}
$object->update_price(1);
}
if ($error)
{
$langs->load("errors");
$db->rollback();
}
setEventMessages($object->error, $object->errors, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
}
else
{
$db->commit();
if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0)
{
$facture_source = new FactureFournisseur($db); // fetch origin object if not previously defined
if ($facture_source->fetch($object->fk_facture_source)>0)
{
$totalpaye = $facture_source->getSommePaiement();
$totalcreditnotes = $facture_source->getSumCreditNotesUsed();
$totaldeposits = $facture_source->getSumDepositsUsed();
$remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits);
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0)
{
dol_print_error($db,$object->error,$object->errors);
exit;
}
}
$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC');
}
}
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
}
// Add predefined lines
/*
TODO delete
for($i = 1; $i <= $NBLINES; $i ++) {
if ($_POST['idprod' . $i]) {
$product = new Product($db);
$product->fetch($_POST['idprod' . $i]);
$startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']);
$endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']);
$result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
}
}*/
}
}
// Standard or deposit
if ($_POST['type'] == FactureFournisseur::TYPE_STANDARD || $_POST['type'] == FactureFournisseur::TYPE_DEPOSIT)
{
if (GETPOST('socid','int')<1)
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')), null, 'errors');
$action='create';
$error++;
}
if ($datefacture == '')
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
$error++;
}
if (! GETPOST('ref_supplier'))
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')), null, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
$error++;
}
if (! $error)
{
$db->begin();
$tmpproject = GETPOST('projectid', 'int');
// Creation facture
$object->ref = $_POST['ref'];
$object->ref_supplier = $_POST['ref_supplier'];
$object->socid = $_POST['socid'];
$object->libelle = $_POST['label'];
$object->date = $datefacture;
$object->date_echeance = $datedue;
$object->note_public = GETPOST('note_public');
$object->note_private = GETPOST('note_private');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
// Auto calculation of date due if not filled by user
if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
// If creation from another object of another module
if (! $error && $_POST['origin'] && $_POST['originid'])
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $_POST['origin'];
/*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}*/
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal'; $subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
if ($element == 'order_supplier') {
$element = 'fourn'; $subelement = 'fournisseur.commande';
}
if ($element == 'project')
{
$element = 'projet';
}
$object->origin = $_POST['origin'];
$object->origin_id = $_POST['originid'];
$id = $object->create($user);
// Add lines
if ($id > 0)
{
require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php';
$classname = ucfirst($subelement);
if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur';
$srcobject = new $classname($db);
$result=$srcobject->fetch($_POST['originid']);
if ($result > 0)
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines'))
{
$srcobject->fetch_lines();
$lines = $srcobject->lines;
}
$num=count($lines);
for ($i = 0; $i < $num; $i++)
{
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
// Dates
// TODO mutualiser
$date_start=$lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
$date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
// FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example.
$result = $object->addline(
$desc,
$lines[$i]->subprice,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$lines[$i]->qty,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$date_start,
$date_end,
0,
$lines[$i]->info_bits,
'HT',
$product_type,
$lines[$i]->rang,
0,
$lines[$i]->array_options,
$lines[$i]->fk_unit,
$lines[$i]->id
);
if ($result < 0)
{
$error++;
break;
}
}
// Now reload line
$object->fetch_lines();
}
else
{
$error++;
}
}
else
{
$error++;
}
}
else if (! $error)
{
$id = $object->create($user);
if ($id < 0)
{
$error++;
}
if (! $error)
{
// If some invoice's lines already known
for ($i = 1 ; $i < 9 ; $i++)
{
$label = $_POST['label'.$i];
$amountht = price2num($_POST['amount'.$i]);
$amountttc = price2num($_POST['amountttc'.$i]);
$tauxtva = price2num($_POST['tauxtva'.$i]);
$qty = $_POST['qty'.$i];
$fk_product = $_POST['fk_product'.$i];
if ($label)
{
if ($amountht)
{
$price_base='HT'; $amount=$amountht;
}
else
{
$price_base='TTC'; $amount=$amountttc;
}
$atleastoneline=1;
$product=new Product($db);
$product->fetch($_POST['idprod'.$i]);
$ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base, $_POST['rang'.$i], 1);
if ($ret < 0) $error++;
}
}
}
}
if ($error)
{
$langs->load("errors");
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
}
else
{
$db->commit();
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0)
{
dol_print_error($db,$object->error,$object->errors);
exit;
}
}
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
}
}
}
// Edit line

View File

@ -708,7 +708,7 @@ if (empty($action))
print '<td>'.$objp->num_paiement.'</td>';
print '<td>';
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/account.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).'</a>';
if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).'</a>';
else print '&nbsp;';
print '</td>';

View File

@ -139,7 +139,8 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp;
ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version);
ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint
ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint;
ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx;
@ -149,4 +150,17 @@ ALTER TABLE llx_commande_fournisseurdet ADD COLUMN vat_src_code varchar(10) DEFA
ALTER TABLE llx_propaldet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx;
ALTER TABLE llx_supplier_proposaldet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx;
ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint;
ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT 0;
create table llx_resource_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;
ALTER TABLE llx_resource_extrafields ADD INDEX idx_resource_extrafields (fk_object);

View File

@ -34,5 +34,6 @@ create table llx_entrepot
fk_pays integer DEFAULT 0,
statut tinyint DEFAULT 1, -- 1 open, 0 close
fk_user_author integer,
import_key varchar(14)
import_key varchar(14),
fk_parent integer DEFAULT 0
)ENGINE=innodb;

View File

@ -0,0 +1,20 @@
-- ===================================================================
-- Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
--
-- 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
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ===================================================================
ALTER TABLE llx_resource_extrafields ADD INDEX idx_resource_extrafields (fk_object);

View File

@ -0,0 +1,26 @@
-- ========================================================================
-- Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
--
-- 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
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ========================================================================
create table llx_resource_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
) ENGINE=innodb;

View File

@ -30,6 +30,7 @@ AccountancyAreaDescContrib=STEP %s: Check the binding between special expences (
AccountancyAreaDescDonation=STEP %s: Check the binding between donation and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on record related to payments of donation.<br>You can set the account dedicated for that from the menu entry %s.
AccountancyAreaDescMisc=STEP %s: Check the default binding between miscellaneous transaction lines and accounting account is done. Complete missing bindings.<br>For this you can use the menu entry %s.
AccountancyAreaDescProd=STEP %s: Check the binding between products/services and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on your invoice lines.<br>For this you can use the menu entry %s.
AccountancyAreaDescLoan=STEP %s: Check the binding between loans payment and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on record related to payment of loans.<br>For this you can use the menu entry %s.
AccountancyAreaDescCustomer=STEP %s: Check the binding between existing customer invoice lines and accounting account is done. Complete missing bindings. Once binding is complete, application will be able to journalize transactions in General Ledger in one click.<br>For this you can use the menu entry %s.
AccountancyAreaDescSupplier=STEP %s: Check the binding between existing supplier invoice lines and accounting account is done. Complete missing bindings. Once binding is complete, application will be able to journalize transactions in General Ledger in one click.<br>For this you can use the menu entry %s.
@ -48,6 +49,7 @@ AccountAccountingSuggest=Accounting account suggest
MenuDefaultAccounts=Default accounts
MenuVatAccounts=Vat accounts
MenuTaxAccounts=Tax accounts
MenuLoanAccounts=Loan accounts
MenuProductsAccounts=Product accounts
ProductsBinding=Products accounts
Ventilation=Binding to accounts
@ -93,9 +95,9 @@ ACCOUNTING_MISCELLANEOUS_JOURNAL=Miscellaneous journal
ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal
ACCOUNTING_SOCIAL_JOURNAL=Social journal
ACCOUNTING_ACCOUNT_TRANSFER_CASH=Account of transfer
ACCOUNTING_ACCOUNT_SUSPENSE=Account of wait
DONATION_ACCOUNTINGACCOUNT=Account to register donations
ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of transfer
ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait
DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations
ACCOUNTING_PRODUCT_BUY_ACCOUNT=Accounting account by default for bought products (used if not defined in the product sheet)
ACCOUNTING_PRODUCT_SOLD_ACCOUNT=Accounting account by default for the sold products (used if not defined in the product sheet)

View File

@ -1631,4 +1631,9 @@ LandingPage=Landing page
SamePriceAlsoForSharedCompanies=If you use a multicompany module, with the choice "Single price", price will be also the same for all companies if products are shared between environments
ModuleEnabledAdminMustCheckRights=Module has been activated. Permissions for activated module(s) were given to admin users only. You may need to grant permissions to other users manually if necessary.
UserHasNoPermissions=This user has no permission defined
TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")<br>Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)<br>Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days")
TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")<br>Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)<br>Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days")
##### Resource ####
ResourceSetup=Configuration du module Resource
UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list).
DisabledResourceLinkUser=Disabled resource link to user
DisabledResourceLinkContact=Disabled resource link to contact

View File

@ -55,35 +55,36 @@ AccountCard=Account card
DeleteAccount=Delete account
ConfirmDeleteAccount=Are you sure you want to delete this account?
Account=Account
BankTransactionByCategories=Bank transactions by categories
BankTransactionForCategory=Bank transactions for category <b>%s</b>
BankTransactionByCategories=Bank entries by categories
BankTransactionForCategory=Bank entries for category <b>%s</b>
RemoveFromRubrique=Remove link with category
RemoveFromRubriqueConfirm=Are you sure you want to remove link between the transaction and the category?
ListBankTransactions=List of bank transactions
RemoveFromRubriqueConfirm=Are you sure you want to remove link between the entry and the category?
ListBankTransactions=List of bank entries
IdTransaction=Transaction ID
BankTransactions=Bank transactions
ListTransactions=List transactions
ListTransactionsByCategory=List transaction/category
TransactionsToConciliate=Transactions to reconcile
BankTransactions=Bank entries
ListTransactions=List entries
ListTransactionsByCategory=List entries/category
TransactionsToConciliate=Entries to reconcile
Conciliable=Can be reconciled
Conciliate=Reconcile
Conciliation=Reconciliation
ReconciliationLate=Reconciliation late
IncludeClosedAccount=Include closed accounts
OnlyOpenedAccount=Only open accounts
AccountToCredit=Account to credit
AccountToDebit=Account to debit
DisableConciliation=Disable reconciliation feature for this account
ConciliationDisabled=Reconciliation feature disabled
LinkedToAConciliatedTransaction=Linked to a conciliated transaction
LinkedToAConciliatedTransaction=Linked to a conciliated entry
StatusAccountOpened=Open
StatusAccountClosed=Closed
AccountIdShort=Number
LineRecord=Transaction
AddBankRecord=Add transaction
AddBankRecordLong=Add transaction manually
AddBankRecord=Add entry
AddBankRecordLong=Add entry manually
ConciliatedBy=Reconciled by
DateConciliating=Reconcile date
BankLineConciliated=Transaction reconciled
BankLineConciliated=Entry reconciled
Reconciled=Reconciled
NotReconciled=Not reconciled
CustomerInvoicePayment=Customer payment
@ -107,13 +108,13 @@ BankChecks=Bank checks
BankChecksToReceipt=Checks awaiting deposit
ShowCheckReceipt=Show check deposit receipt
NumberOfCheques=Nb of check
DeleteTransaction=Delete transaction
ConfirmDeleteTransaction=Are you sure you want to delete this transaction?
ThisWillAlsoDeleteBankRecord=This will also delete generated bank transactions
DeleteTransaction=Delete entry
ConfirmDeleteTransaction=Are you sure you want to delete this entry?
ThisWillAlsoDeleteBankRecord=This will also delete generated bank entry
BankMovements=Movements
PlannedTransactions=Planned transactions
PlannedTransactions=Planned entries
Graph=Graphics
ExportDataset_banque_1=Bank transactions and account statement
ExportDataset_banque_1=Bank entries and account statement
ExportDataset_banque_2=Deposit slip
TransactionOnTheOtherAccount=Transaction on the other account
PaymentNumberUpdateSucceeded=Payment number updated successfully
@ -121,7 +122,7 @@ PaymentNumberUpdateFailed=Payment number could not be updated
PaymentDateUpdateSucceeded=Payment date updated successfully
PaymentDateUpdateFailed=Payment date could not be updated
Transactions=Transactions
BankTransactionLine=Bank transaction
BankTransactionLine=Bank entry
AllAccounts=All bank/cash accounts
BackToAccount=Back to account
ShowAllAccounts=Show for all accounts

View File

@ -421,6 +421,7 @@ ShowUnpaidAll=Show all unpaid invoices
ShowUnpaidLateOnly=Show late unpaid invoices only
PaymentInvoiceRef=Payment invoice %s
ValidateInvoice=Validate invoice
ValidateInvoices=Validate invoices
Cash=Cash
Reported=Delayed
DisabledBecausePayments=Not possible since there are some payments
@ -482,4 +483,5 @@ ToCreateARecurringInvoiceGene=To generate future invoices regularly and manually
ToCreateARecurringInvoiceGeneAuto=If you need to have such invoices generated automatically, ask you administrator to enable and setup module <strong>%s</strong>. Note that both method (manual and automatic) can be used together with no risk of duplication.
DeleteRepeatableInvoice=Delete template invoice
ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice?
CreateOneBillByThird=Create one bill by third
BillCreated=%s bill(s) created

View File

@ -271,7 +271,7 @@ DefaultContact=Default contact/address
AddThirdParty=Create third party
DeleteACompany=Delete a company
PersonalInformations=Personal data
AccountancyCode=Accountancy code
AccountancyCode=Accounting account
CustomerCode=Customer code
SupplierCode=Supplier code
CustomerCodeShort=Customer code

View File

@ -69,7 +69,7 @@ ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete.
ErrorLDAPMakeManualTest=A .ldif file has been generated in directory %s. Try to load it manually from command line to have more information on errors.
ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "statut not started" if field "done by" is also filled.
ErrorRefAlreadyExists=Ref used for creation already exists.
ErrorPleaseTypeBankTransactionReportName=Please type bank receipt name where transaction is reported (Format YYYYMM or YYYYMMDD)
ErrorPleaseTypeBankTransactionReportName=Please type bank statement name where entry is reported (Format YYYYMM or YYYYMMDD)
ErrorRecordHasChildren=Failed to delete record since it has some childs.
ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into other object.
ErrorModuleRequireJavascript=Javascript must not be disabled to have this feature working. To enable/disable Javascript, go to menu Home->Setup->Display.
@ -131,7 +131,7 @@ ErrorWarehouseMustDiffers=Source and target warehouses must differs
ErrorBadFormat=Bad format!
ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst=Error, this member is not yet linked to any third party. Link member to an existing third party or create a new third party before creating subscription with invoice.
ErrorThereIsSomeDeliveries=Error, there is some deliveries linked to this shipment. Deletion refused.
ErrorCantDeletePaymentReconciliated=Can't delete a payment that had generated a bank transaction that was conciliated
ErrorCantDeletePaymentReconciliated=Can't delete a payment that had generated a bank entry that was reconciled
ErrorCantDeletePaymentSharedWithPayedInvoice=Can't delete a payment shared by at least one invoice with status Payed
ErrorPriceExpression1=Cannot assign to constant '%s'
ErrorPriceExpression2=Cannot redefine built-in function '%s'
@ -177,6 +177,7 @@ ErrorStockIsNotEnoughToAddProductOnProposal=Stock is not enougth for product %s
ErrorFailedToLoadLoginFileForMode=Failed to get the login file for mode '%s'.
ErrorModuleNotFound=File of module was not found.
ErrorFieldAccountNotDefinedForBankLine=Value for Accounting account not defined for source bank line %s
ErrorBankStatementNameMustFollowRegex=Error, bank statement name must follow the following syntax rule %s
# Warnings
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.

View File

@ -175,7 +175,7 @@ MigrationReopeningContracts=Open contract closed by error
MigrationReopenThisContract=Reopen contract %s
MigrationReopenedContractsNumber=%s contracts modified
MigrationReopeningContractsNothingToUpdate=No closed contract to open
MigrationBankTransfertsUpdate=Update links between bank transaction and a bank transfer
MigrationBankTransfertsUpdate=Update links between bank entry and a bank transfer
MigrationBankTransfertsNothingToUpdate=All links are up to date
MigrationShipmentOrderMatching=Sendings receipt update
MigrationDeliveryOrderMatching=Delivery receipt update

View File

@ -10,9 +10,9 @@ LoanCapital=Capital
Insurance=Insurance
Interest=Interest
Nbterms=Number of terms
LoanAccountancyCapitalCode=Accountancy code capital
LoanAccountancyInsuranceCode=Accountancy code insurance
LoanAccountancyInterestCode=Accountancy code interest
LoanAccountancyCapitalCode=Accounting account capital
LoanAccountancyInsuranceCode=Accounting account insurance
LoanAccountancyInterestCode=Accounting account interest
ConfirmDeleteLoan=Confirm deleting this loan
LoanDeleted=Loan Deleted Successfully
ConfirmPayLoan=Confirm classify paid this loan
@ -45,6 +45,6 @@ GoToPrincipal=%s will go towards PRINCIPAL
YouWillSpend=You will spend %s in year %s
# Admin
ConfigLoan=Configuration of the module loan
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default
LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accountancy code interest by default
LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accountancy code insurance by default
LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accounting account capital by default
LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accounting account interest by default
LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accounting account insurance by default

View File

@ -62,6 +62,7 @@ ErrorCantLoadUserFromDolibarrDatabase=Failed to find user <b>%s</b> in Dolibarr
ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '%s'.
ErrorNoSocialContributionForSellerCountry=Error, no social/fiscal taxes type defined for country '%s'.
ErrorFailedToSaveFile=Error, failed to save file.
ErrorCannotAddThisParentWarehouse=You are trying to add a parent warehouse which is already a child of current one
NotAuthorized=You are not authorized to do that.
SetDate=Set date
SelectDate=Select a date
@ -705,7 +706,7 @@ PublicUrl=Public URL
AddBox=Add box
SelectElementAndClickRefresh=Select an element and click Refresh
PrintFile=Print File %s
ShowTransaction=Show transaction on bank account
ShowTransaction=Show entry on bank account
GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide.
Deny=Deny
Denied=Denied
@ -721,7 +722,7 @@ DeleteLine=Delete line
ConfirmDeleteLine=Are you sure you want to delete this line?
NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked records
TooManyRecordForMassAction=Too many record selected for mass action. The action is restricted to a list of %s records.
NoRecordSelected=No record were selected
NoRecordSelected=No record selected
MassFilesArea=Area for files built by mass actions
ShowTempMassFilesArea=Show area of files built by mass actions
RelatedObjects=Related Objects

View File

@ -127,8 +127,8 @@ NoThirdPartyAssociatedToMember=No third party associated to this member
MembersAndSubscriptions= Members and Subscriptions
MoreActions=Complementary action on recording
MoreActionsOnSubscription=Complementary action, suggested by default when recording a subscription
MoreActionBankDirect=Create a direct transaction record on account
MoreActionBankViaInvoice=Create an invoice and payment on account
MoreActionBankDirect=Create a direct entry on bank account
MoreActionBankViaInvoice=Create an invoice, and a payment on bank account
MoreActionInvoiceOnly=Create an invoice with no payment
LinkToGeneratedPages=Generate visit cards
LinkToGeneratedPagesDesc=This screen allows you to generate PDF files with business cards for all your members or a particular member.

View File

@ -4,7 +4,7 @@ ErrorAddRateFail=Error in added rate
ErrorAddCurrencyFail=Error in added currency
ErrorDeleteCurrencyFail=Error delete fail
multicurrency_syncronize_error=Error in synchronization
multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the new rate entered)
multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the new known rate)
CurrencyLayerAccount=CurrencyLayer API
CurrencyLayerAccount_help_to_synchronize=You sould create an account on their website to use this functionnality<br />Get your <b>API key</b><br />If you use a free account you can't change the <b>currency source</b> (USD by default)<br />But if your main currency isn't USD you can use the <b>alternate currency source</b> to force you main currency<br /><br />You are limited at 1000 synchronizations per month
multicurrency_appId=API key

View File

@ -2,6 +2,7 @@
WarehouseCard=Warehouse card
Warehouse=Warehouse
Warehouses=Warehouses
ParentWarehouse=Parent warehouse
NewWarehouse=New warehouse / Stock area
WarehouseEdit=Modify warehouse
MenuNewWarehouse=New warehouse

View File

@ -56,15 +56,18 @@ class FormProduct
* @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''.
* @param int $status additional filter on status other then 1
* @param boolean $sumStock sum total stock of a warehouse, default true
* @param array $exclude warehouses ids to exclude
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
*/
function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true)
function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true, $exclude='')
{
global $conf, $langs;
if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product
$sql = "SELECT e.rowid, e.label, e.description";
if (is_array($exclude)) $excludeGroups = implode("','",$exclude);
$sql = "SELECT e.rowid, e.label, e.description, e.fk_parent";
if (!empty($fk_product))
{
if (!empty($batch))
@ -100,6 +103,8 @@ class FormProduct
$sql.= " AND e.statut = 1";
}
if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.implode(',', $exclude).')';
if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description";
$sql.= " ORDER BY e.label";
@ -115,10 +120,17 @@ class FormProduct
if ($sumStock) $obj->stock = price2num($obj->stock,5);
$this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid;
$this->cache_warehouses[$obj->rowid]['label']=$obj->label;
$this->cache_warehouses[$obj->rowid]['parent_id']=$obj->fk_parent;
$this->cache_warehouses[$obj->rowid]['description'] = $obj->description;
$this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock;
$i++;
}
// Full label init
foreach($this->cache_warehouses as $obj_rowid=>$tab) {
$this->cache_warehouses[$obj_rowid]['full_label'] = $this->get_parent_path($tab);
}
return $num;
}
else
@ -127,6 +139,29 @@ class FormProduct
return -1;
}
}
/**
* Return full path to current warehouse in $tab (recursive function)
*
* @param array $tab warehouse data in $this->cache_warehouses line
* @param String $final_label full label with all parents, separated by ' >> ' (completed on each call)
* @return String full label with all parents, separated by ' >> '
*/
private function get_parent_path($tab, $final_label='') {
if(empty($final_label)) $final_label = $tab['label'];
if(empty($tab['parent_id'])) return $final_label;
else {
if(!empty($this->cache_warehouses[$tab['parent_id']])) {
$final_label = $this->cache_warehouses[$tab['parent_id']]['label'].' >> '.$final_label;
return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label);
}
}
return $final_label;
}
/**
* Return list of warehouses
@ -142,9 +177,10 @@ class FormProduct
* @param int $forcecombo force combo iso ajax select2
* @param array $events events to add to select2
* @param string $morecss Add more css classes
* @param array $exclude warehouses ids to exclude
* @return string HTML select
*/
function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200')
function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200', $exclude='')
{
global $conf,$langs,$user;
@ -152,7 +188,7 @@ class FormProduct
$out='';
$this->loadWarehouses($fk_product, '', + $filtertype); // filter on numeric status
$this->loadWarehouses($fk_product, '', + $filtertype, true, $exclude); // filter on numeric status
$nbofwarehouses=count($this->cache_warehouses);
if ($conf->use_javascript_ajax && ! $forcecombo)
@ -170,7 +206,7 @@ class FormProduct
$out.='<option value="'.$id.'"';
if ($selected == $id || ($selected == 'ifone' && $nbofwarehouses == 1)) $out.=' selected';
$out.='>';
$out.=$arraytypes['label'];
$out.=$arraytypes['full_label'];
if (($fk_product || ($showstock > 0)) && ($arraytypes['stock'] != 0 || ($showstock > 0))) $out.=' ('.$langs->trans("Stock").':'.$arraytypes['stock'].')';
$out.='</option>';
}

View File

@ -31,10 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$langs->load("products");
$langs->load("stocks");
$langs->load("companies");
$langs->load("categories");
$action=GETPOST('action');
$cancel=GETPOST('cancel');
@ -64,6 +66,7 @@ $object = new Entrepot($db);
if ($action == 'add' && $user->rights->stock->creer)
{
$object->ref = GETPOST("ref");
$object->fk_parent = GETPOST("fk_parent");
$object->libelle = GETPOST("libelle");
$object->description = GETPOST("desc");
$object->statut = GETPOST("statut");
@ -128,6 +131,7 @@ if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
if ($object->fetch($id))
{
$object->libelle = GETPOST("libelle");
$object->fk_parent = GETPOST("fk_parent");
$object->description = GETPOST("desc");
$object->statut = GETPOST("statut");
$object->lieu = GETPOST("lieu");
@ -166,6 +170,7 @@ if ($cancel == $langs->trans("Cancel"))
$productstatic=new Product($db);
$form=new Form($db);
$formproduct=new FormProduct($db);
$formcompany=new FormCompany($db);
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
@ -189,6 +194,11 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="20" value=""></td></tr>';
print '<tr><td >'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.(!empty($object->lieu)?$object->lieu:'').'"></td></tr>';
// Parent entrepot
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formproduct->selectWarehouses('', 'fk_parent', '', 1);
print '</td></tr>';
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
@ -346,6 +356,16 @@ else
//print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$object->lieu.'</td></tr>';
// Parent entrepot
$e = new Entrepot($db);
if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) {
print '<tr><td>'.$langs->trans("ParentWarehouse").'</td><td>';
print $e->getNomUrl(3);
print '</td></tr>';
}
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'.nl2br($object->description).'</td></tr>';
@ -623,6 +643,11 @@ else
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="20" value="'.$object->libelle.'"></td></tr>';
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$object->lieu.'"></td></tr>';
// Parent entrepot
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1);
print '</td></tr>';
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';

View File

@ -123,8 +123,8 @@ class Entrepot extends CommonObject
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label)";
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."')";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label, fk_parent)";
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."', ".($this->fk_parent > 0 ? $this->fk_parent : 'NULL').")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result=$this->db->query($sql);
@ -172,6 +172,16 @@ class Entrepot extends CommonObject
*/
function update($id, $user)
{
// Check if new parent is already a child of current warehouse
if(!empty($this->fk_parent)) {
$TChildWarehouses = array($id);
$TChildWarehouses = $this->get_children_warehouses($this->id, $TChildWarehouses);
if(in_array($this->fk_parent, $TChildWarehouses)) {
$this->error = 'ErrorCannotAddThisParentWarehouse';
return -2;
}
}
$this->libelle=trim($this->libelle);
$this->description=trim($this->description);
@ -184,6 +194,7 @@ class Entrepot extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
$sql .= " SET label = '" . $this->db->escape($this->libelle) ."'";
$sql .= ", fk_parent = '" . (($this->fk_parent > 0) ? $this->fk_parent : 'NULL') ."'";
$sql .= ", description = '" . $this->db->escape($this->description) ."'";
$sql .= ", statut = " . $this->statut;
$sql .= ", lieu = '" . $this->db->escape($this->lieu) ."'";
@ -294,7 +305,7 @@ class Entrepot extends CommonObject
{
global $conf;
$sql = "SELECT rowid, label, description, statut, lieu, address, zip, town, fk_pays as country_id";
$sql = "SELECT rowid, fk_parent, label, description, statut, lieu, address, zip, town, fk_pays as country_id";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
if ($id)
@ -317,6 +328,7 @@ class Entrepot extends CommonObject
$obj=$this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->fk_parent = $obj->fk_parent;
$this->ref = $obj->rowid;
$this->libelle = $obj->label;
$this->description = $obj->description;
@ -573,7 +585,7 @@ class Entrepot extends CommonObject
$linkend='</a>';
if ($withpicto) $result.=($link.img_object($label, 'stock', 'class="classfortooltip"').$linkend.' ');
$result.=$link.(empty($this->label)?$this->libelle:$this->label).$linkend;
$result.=$link.$this->get_full_arbo().$linkend;
return $result;
}
@ -604,4 +616,69 @@ class Entrepot extends CommonObject
$this->country_id=1;
$this->country_code='FR';
}
/**
* Return full path to current warehouse
*
* @param int $protection Deep counter to avoid infinite loop
* @return string String full path to current warehouse separated by " >> "
*/
function get_full_arbo($protection=1000) {
global $user,$langs,$conf;
$TArbo = array($this->libelle);
$id = $this->id;
$i=0;
while((empty($protection) || $i < $protection)) {
$sql = 'SELECT fk_parent
FROM '.MAIN_DB_PREFIX.'entrepot
WHERE rowid = '.$id;
$resql = $this->db->query($sql);
if($resql) {
$res = $this->db->fetch_object($resql);
if(empty($res->fk_parent)) break;
$id = $res->fk_parent;
$o = new Entrepot($this->db);
$o->fetch($id);
$TArbo[] = $o->libelle;
} else break;
$i++;
}
return implode(' >> ', array_reverse($TArbo));
}
/**
* Return array of children warehouses ids from $id warehouse (recursive function)
*
* @param int $id id parent warehouse
* @param array() $TChildWarehouses array which will contain all children (param by reference)
* @return array() $TChildWarehouses array which will contain all children
*/
function get_children_warehouses($id, &$TChildWarehouses) {
$sql = 'SELECT rowid
FROM '.MAIN_DB_PREFIX.'entrepot
WHERE fk_parent = '.$id;
$resql = $this->db->query($sql);
if($resql) {
while($res = $this->db->fetch_object($resql)) {
$TChildWarehouses[] = $res->rowid;
$this->get_children_warehouses($res->rowid, $TChildWarehouses);
}
}
return $TChildWarehouses;
}
}

View File

@ -970,7 +970,16 @@ else
{
if ($action != "edit" )
{
// Modify
// Create event
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
// "workflow" action so should appears somewhere else on
// page.
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '&amp;projectid=' . $object->id . '">' . $langs->trans("AddAction") . '</a></div>';
}
// Modify
if ($object->statut != 2 && $user->rights->projet->creer)
{
if ($userWrite > 0)

View File

@ -27,6 +27,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load traductions files required by page
$langs->load("resource");
@ -60,6 +61,11 @@ if ($user->societe_id > 0)
$object = new DolResource($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
if ($action == 'confirm_add_resource')
{
if (! $cancel)
@ -84,6 +90,12 @@ if ($action == 'confirm_add_resource')
$object->description=$description;
$object->fk_code_type_resource=$fk_code_type_resource;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) {
$error ++;
}
$result=$object->create($user);
if ($result > 0)
{
@ -162,6 +174,15 @@ if (! $action)
print '</td>';
print '</tr>';
// Other attributes
$parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
}
print '</table>';
dol_fiche_end('');

View File

@ -29,9 +29,10 @@ if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
if (! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once 'class/dolresource.class.php';
require_once 'class/html.formresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load traductions files requiredby by page
$langs->load("resource");
@ -58,6 +59,11 @@ if( ! $user->rights->resource->read)
$object = new Dolresource($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$hookmanager->initHooks(array('resource_card','globalcard'));
$parameters=array('resource_id'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@ -88,6 +94,12 @@ if (empty($reshook))
$object->description = $description;
$object->fk_code_type_resource = $fk_code_type_resource;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
if ($ret < 0) {
$error ++;
}
$result=$object->update($user);
if ($result > 0)
{
@ -126,7 +138,7 @@ if (empty($reshook))
Header('Location: '.DOL_URL_ROOT.'/resource/list.php');
exit;
}
else
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
@ -188,6 +200,14 @@ if ( $object->fetch($id) > 0 )
print '<textarea name="description" cols="80" rows="'.ROWS_3.'">'.($_POST['description'] ? GETPOST('description','alpha') : $object->description).'</textarea>';
print '</td></tr>';
// Other attributes
$parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
}
print '</table>';
dol_fiche_end();
@ -235,6 +255,15 @@ if ( $object->fetch($id) > 0 )
print '<td>';
print $object->description;
print '</td>';
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields);
}
print '</tr>';
print '</table>';

View File

@ -63,7 +63,7 @@ class Dolresource extends CommonObject
*/
function create($user, $notrigger=0)
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$error=0;
// Clean parameters
@ -107,14 +107,40 @@ class Dolresource extends CommonObject
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
}
if (! $error)
{
$action='create';
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
}
if (! $error)
{
if (! $notrigger)
{
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('RESOURCE_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('RESOURCE_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
@ -177,6 +203,13 @@ class Dolresource extends CommonObject
$this->note_private = $obj->note_private;
$this->type_label = $obj->type_label;
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
$this->fetch_optionals($this->id,$extralabels);
}
$this->db->free($resql);
@ -199,7 +232,7 @@ class Dolresource extends CommonObject
*/
function update($user=null, $notrigger=0)
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$error=0;
// Clean parameters
@ -229,13 +262,35 @@ class Dolresource extends CommonObject
// want this action calls a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('RESOURCE_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
if (! $error)
{
$action='update';
// Actions on extra fields (by external module or standard code)
// TODO le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('actioncommdao'));
$parameters=array('actcomm'=>$this->id);
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
}
else if ($reshook < 0) $error++;
}
// Commit or rollback
if ($error)
@ -294,10 +349,12 @@ class Dolresource extends CommonObject
$this->mandatory = $obj->mandatory;
$this->fk_user_create = $obj->fk_user_create;
if($obj->resource_id && $obj->resource_type)
if($obj->resource_id && $obj->resource_type) {
$this->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type);
if($obj->element_id && $obj->element_type)
}
if($obj->element_id && $obj->element_type) {
$this->objelement = fetchObjectByElement($obj->element_id,$obj->element_type);
}
}
$this->db->free($resql);
@ -324,36 +381,57 @@ class Dolresource extends CommonObject
$error=0;
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('RESOURCE_DELETE',$user);
if ($result < 0) return -1;
// End call triggers
}
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE rowid =".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
dol_syslog(get_class($this), LOG_DEBUG);
if ($this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
$sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($this->db->query($sql))
$resql=$this->db->query($sql);
if (!$resql)
{
return 1;
}
else {
$this->error=$this->db->lasterror();
return -1;
$this->error=$this->db->lasterror();
$error++;
}
}
else
{
$this->error=$this->db->lasterror();
return -1;
$error++;
}
// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('RESOURCE_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
}
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
}
}
@ -377,9 +455,20 @@ class Dolresource extends CommonObject
$sql.= " t.description,";
$sql.= " t.fk_code_type_resource,";
$sql.= " t.tms,";
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
if (is_array($extralabels) && count($extralabels)>0) {
foreach($extralabels as $label=>$code) {
$sql.= " ef.".$code." as extra_".$code.",";
}
}
$sql.= " ty.label as type_label";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid";
$sql.= " WHERE t.entity IN (".getEntity('resource',1).")";
//Manage filter
@ -388,6 +477,9 @@ class Dolresource extends CommonObject
if (strpos($key,'date')) {
$sql.= ' AND '.$key.' = \''.$this->db->idate($value).'\'';
}
elseif (strpos($key,'ef.')!==false){
$sql.= $value;
}
else {
$sql.= ' AND '.$key.' LIKE \'%'.$value.'%\'';
}
@ -419,6 +511,11 @@ class Dolresource extends CommonObject
$line->fk_code_type_resource = $obj->fk_code_type_resource;
$line->type_label = $obj->type_label;
// Retreive all extrafield for thirdparty
// fetch optionals attributes and labels
$line->fetch_optionals($line->id,$extralabels);
$this->lines[] = $line;
}
$this->db->free($resql);

View File

@ -41,28 +41,103 @@ $resource_id = GETPOST('resource_id','int');
$sortorder = GETPOST('sortorder','alpha');
$sortfield = GETPOST('sortfield','alpha');
$page = GETPOST('page','int');
// Initialize context for list
$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'resourcelist';
$object = new Dolresource($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
$search_ref=GETPOST("search_ref");
$search_type=GETPOST("search_type");
$filter=array();
if ($search_ref != ''){
$param.='&search_ref='.$search_ref;
$filter['t.ref']=$search_ref;
}
if ($search_type != ''){
$param.='&search_type='.$search_type;
$filter['ty.label']=$search_type;
}
if ($search_label != '') $param.='&search_label='.$search_label;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
if ($val != '') {
$param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
$mode=0;
if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric
if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit)))
{
$filter['ef.'.$tmpkey]=natural_search('ef.'.$tmpkey, $crit, $mode);
}
}
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
$hookmanager->initHooks(array('resource_list'));
if (empty($sortorder)) $sortorder="ASC";
if (empty($sortfield)) $sortfield="t.rowid";
if (empty($arch)) $arch = 0;
$page = GETPOST('page','int');
if ($page == -1) {
$page = 0 ;
$page = 0 ;
}
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
$offset = $limit * $page ;
$page = is_numeric($page) ? $page : 0;
$page = $page == -1 ? 0 : $page;
if (! $sortfield) $sortfield="p.ref";
if (! $sortorder) $sortorder="ASC";
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if( ! $user->rights->resource->read)
if( ! $user->rights->resource->read) {
accessforbidden();
}
$arrayfields = array(
't.ref' => array(
'label' => $langs->trans("Ref"),
'checked' => 1
),
'ty.label' => array(
'label' => $langs->trans("ResourceType"),
'checked' => 1
),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
foreach ( $extrafields->attribute_label as $key => $val ) {
$arrayfields["ef." . $key] = array(
'label' => $extrafields->attribute_label[$key],
'checked' => $extrafields->attribute_list[$key],
'position' => $extrafields->attribute_pos[$key],
'enabled' => $extrafields->attribute_perms[$key]
);
}
}
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$search_ref="";
$search_label="";
$search_array_options=array();
$filter=array();
}
/*
* Action
@ -73,7 +148,6 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
/*
* View
*/
@ -86,11 +160,11 @@ llxHeader('',$pagetitle,'');
// Confirmation suppression resource line
if ($action == 'delete_resource')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1);
print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1);
}
// Load object list
$ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset);
$ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset, $filter);
if($ret == -1) {
dol_print_error($db,$object->error);
exit;
@ -100,11 +174,78 @@ if($ret == -1) {
$var=true;
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'t.ref','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans('ResourceType'),$_SERVER['PHP_SELF'],'ty.code','',$param,'',$sortfield,$sortorder);
print_liste_field_titre('',"","","","",'width="60" align="center"',"","");
if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['ty.label']['checked'])) print_liste_field_titre($arrayfields['ty.label']['label'],$_SERVER["PHP_SELF"],"t.code","",$param,"",$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
}
}
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['t.ref']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_ref" value="'.$search_ref.'" size="6">';
print '</td>';
}
if (! empty($arrayfields['ty.label']['checked']))
{
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_type" value="'.$search_type.'" size="6">';
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
}
// Action column
print '<td class="liste_titre" align="right">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
print $searchpitco;
print '</td>';
print "</tr>\n";
if ($ret)
@ -118,13 +259,37 @@ if ($ret)
print '<tr '.$bc[$var].' '.$style.'>';
print '<td>';
print $resource->getNomUrl(5);
print '</td>';
if (! empty($arrayfields['t.ref']['checked']))
{
print '<td>';
print $resource->getNomUrl(5);
print '</td>';
}
print '<td>';
print $resource->type_label;
print '</td>';
if (! empty($arrayfields['ty.label']['checked']))
{
print '<td>';
print $resource->type_label;
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1);
print '</td>';
}
}
if (! $i) $totalarray['nbfield']++;
}
print '<td align="center">';
print '<a href="./card.php?action=edit&id='.$resource->id.'">';
@ -140,6 +305,7 @@ if ($ret)
}
print '</table>';
print "</form>\n";
}
else
{

View File

@ -2185,7 +2185,7 @@ class Societe extends CommonObject
*
* @param int $rowid id of contact
* @param string $mode 'email' or 'mobile'
* @return string email of contact
* @return string Email of contact with format: "Full name <email>"
*/
function contact_get_property($rowid,$mode)
{

View File

@ -624,8 +624,9 @@ div.myavailability {
.maxwidth500 { max-width: 500px; }
.minheight20 { min-height: 20px; }
.minheight40 { min-height: 40px; }
.titlefield { width: 25%; }
.titlefieldcreate { width: 20%; }
.titlefield { width: 25%; }
.titlefieldmiddle { width: 50%; }
/* Force values for small screen */
@media only screen and (max-width: 1400px)

View File

@ -618,8 +618,9 @@ div.myavailability {
.maxwidth500 { max-width: 500px; }
.minheight20 { min-height: 20px; }
.minheight40 { min-height: 40px; }
.titlefield { width: 25%; }
.titlefieldcreate { width: 20%; }
.titlefield { width: 25%; }
.titlefieldmiddle { width: 50%; }
/* Force values for small screen */
@media only screen and (max-width: 1400px)

View File

@ -1784,15 +1784,6 @@ else
dol_fiche_head($head, 'user', $title, 0, 'user');
$rowspan=22;
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++;
if (! empty($conf->societe->enabled)) $rowspan++;
if (! empty($conf->adherent->enabled)) $rowspan++;
if (! empty($conf->skype->enabled)) $rowspan++;
if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $rowspan = $rowspan+3;
if (! empty($conf->agenda->enabled)) $rowspan++;
if (! empty($conf->accounting->enabled)) $rowspan++;
print '<table width="100%" class="border">';
// Ref/ID
@ -1819,12 +1810,6 @@ else
print $object->lastname;
}
print '</td>';
// Photo
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
print $form->showphoto('userphoto',$object,100,0,$caneditfield,'photowithmargin','small');
print '</td>';
print '</tr>';
// Firstname
@ -1841,6 +1826,14 @@ else
}
print '</td></tr>';
// Photo
print '<tr>';
print '<td>'.$langs->trans("Photo").'</td>';
print '<td valign="middle">';
print $form->showphoto('userphoto',$object,100,0,$caneditfield,'photowithmargin','small');
print '</td>';
print '</tr>';
// Employee
print '<tr>';
print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';

View File

@ -177,7 +177,22 @@ class CMailFileTest extends PHPUnit_Framework_TestCase
$result=$localobject->getValidAddress($src,3,1);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result,'"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>');
$src='John Doe <john@doe.com>';
$result=$localobject->getValidAddress($src,4);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result,'John Doe');
$src='John Doe <john@doe.com>, John Doe2 <john@doe3.com>, John Doe3 <john@doe2.com>';
$result=$localobject->getValidAddress($src,4);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result,'John Doe,John Doe2,John Doe3');
$src='John Doe <john@doe.com>, John Doe2 <john@doe3.com>, John Doe3 <john@doe2.com>';
$result=$localobject->getValidAddress($src,4,0,2);
print __METHOD__." result=".$result."\n";
$this->assertEquals($result,'John Doe,John Doe2...');
return $result;
}