diff --git a/COPYRIGHT b/COPYRIGHT index df0ba8b3e90..40822059ab0 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -26,6 +26,7 @@ php-iban 1.4.6 LGPL-3+ Yes PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests Restler 3.0 LGPL-3+ Yes Library to develop REST Web services TCPDF 6.2.6 LGPL-3+ Yes PDF generation +EvalMath 1.0 BSD Yes Safe math expressions evaluation JS libraries: jQuery 1.11.3 MIT License Yes JS library diff --git a/ChangeLog b/ChangeLog index 3a882e1bb30..8bc845021b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -235,6 +235,8 @@ FIX [ bug 1634 ] Error deleting a project when it had many linked objects FIX [ bug 1925 ] "Link to order" option in supplier invoices is not working properly FIX [ bug #3198 ] Trigger LINECONTRACT_INSERT passes Contrat as $object instead of ContratLigne FIX: Not showing delivery date on rouget pdf +FIX: Not showing task extrafields when creating from left menu +FIX [ bug #3288 ] Tasks box is not properly drawn NEW: Created new ContratLigne::insert function @@ -494,6 +496,10 @@ Dolibarr better: - Fix: Bad permission assignments for stock movements actions - Fix: [ bug #2891 ] Category hooks do not work - Fix: [ bug #2696 ] Adding complementary attribute fails if code is numerics +- Fix: [ bug #3074 ] Accruals accounting use payment date instead of commitment date in turnover reports for salaries +- Fix: Not showing product supplier reference when page break +- Fix: [ bug #3341 ] Missing translation in /compta/paiement_charge.php +- Fix: [ bug #3342 ] Taxes dictionary page does not accept localized decimals for localtax2 rate ***** ChangeLog for 3.6.2 compared to 3.6.1 ***** - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice. @@ -677,6 +683,7 @@ Fix: [ bug #2715 ] Statistics page has broken layout with long thirdparty names Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result +Fix: [ bug #1791 ] Margin menu not available if any Finance module is not enabled ***** ChangeLog for 3.5.6 compared to 3.5.5 ***** Fix: Avoid missing class error for fetch_thirdparty method #1973 diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index 31578905202..aaaa1fdb33a 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # \file dolibarr.pl # \brief Dolibarr script install for Virtualmin Pro -# \author (c)2009-2012 Regis Houssin +# \author (c)2009-2015 Regis Houssin #---------------------------------------------------------------------------- @@ -30,8 +30,7 @@ return "Regis Houssin"; # script_dolibarr_versions() sub script_dolibarr_versions { - # TODO Replace this with version of Dolibar we want to install - return ( "x.y.z", "3.6.0"); +return ( "3.7.2", "3.6.3", "3.5.6" ); } sub script_dolibarr_category @@ -57,6 +56,26 @@ local ($d, $ver) = @_; return ("mysql", "postgres"); } +# script_dolibarr_depends(&domain, version) +sub script_dolibarr_depends +{ +local ($d, $ver, $sinfo, $phpver) = @_; +local @rv; + +if ($ver >= 3.6) { + # Check for PHP 5.3+ + local $phpv = &get_php_version($phpver || 5, $d); + if (!$phpv) { + push(@rv, "Could not work out exact PHP version"); + } + elsif ($phpv < 5.3) { + push(@rv, "Dolibarr requires PHP version 5.3 or later"); + } + } + +return @rv; +} + # script_dolibarr_params(&domain, version, &upgrade-info) # Returns HTML for table rows for options for installing dolibarr sub script_dolibarr_params @@ -78,8 +97,7 @@ else { $rv .= &ui_table_row("Database for Dolibarr tables", &ui_database_select("db", undef, \@dbs, $d, "dolibarr")); $rv .= &ui_table_row("Install sub-directory under $hdir", - &ui_opt_textbox("dir", "dolibarr", 30, - "At top level")); + &ui_opt_textbox("dir", &substitute_scriptname_template("dolibarr", $d), 30, "At top level")); if ($d->{'ssl'} && $ver >= 3.0) { $rv .= &ui_table_row("Force https connection?", &ui_yesno_radio("forcehttps", 0)); @@ -159,7 +177,8 @@ if ($opts->{'newdb'} && !$upgrade) { local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2); local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d); local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1); -local $dbphptype = $dbtype eq "mysql" ? "mysqli" : "pgsql"; +local $dbphptype = $dbtype eq "mysql" && $version >= 3.6 ? "mysql" : + $dbtype eq "mysql" ? "mysqli" : "pgsql"; local $dbhost = &get_database_host($dbtype); local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass); return (0, "Database connection failed : $dberr") if ($dberr); @@ -201,12 +220,10 @@ if ($opts->{'path'} =~ /\w/) { if (!$upgrade) { local $cdef = "$opts->{'dir'}/conf/conf.php.example"; &run_as_domain_user($d, "cp ".quotemeta($cdef)." ".quotemeta($cfile)); - &set_ownership_permissions(undef, undef, 0777, $cfiledir); - &set_ownership_permissions(undef, undef, 0666, $cfile); + &set_permissions_as_domain_user($d, 0777, $cfiledir); + &set_permissions_as_domain_user($d, 0666, $cfile); &run_as_domain_user($d, "mkdir ".quotemeta($docdir)); - &set_ownership_permissions(undef, undef, 0777, $docdir); - &run_as_domain_user($d, "mkdir ".quotemeta($altdir)); - &set_ownership_permissions(undef, undef, 0777, $altdir); + &set_permissions_as_domain_user($d, 0777, $docdir); } else { # Preserve old config file, documents and custom directory @@ -289,8 +306,8 @@ else { local $dinstall = "$opts->{'dir'}/install"; $dinstall =~ s/\/$//; $out = &run_as_domain_user($d, "rm -rf ".quotemeta($dinstall)); - &set_ownership_permissions(undef, undef, 0644, $cfile); - &set_ownership_permissions(undef, undef, 0755, $cfiledir); + &set_permissions_as_domain_user($d, 0644, $cfile); + &set_permissions_as_domain_user($d, 0755, $cfiledir); } # Return a URL for the user @@ -309,6 +326,7 @@ local $ipage = $opts->{'path'}."/install/".$page.".php"; local ($iout, $ierror); &post_http_connection($d, $ipage, $params, \$iout, \$ierror); +print STDERR $iout; if ($ierror) { return $ierror; @@ -329,10 +347,10 @@ local $derr = &delete_script_install_directory($d, $opts); return (0, $derr) if ($derr); # Remove all llx_ tables from the database -# 3 times because of constraints -&cleanup_script_database($d, $opts->{'db'}, "llx_"); -&cleanup_script_database($d, $opts->{'db'}, "llx_"); -&cleanup_script_database($d, $opts->{'db'}, "llx_"); +# 4 times because of constraints +for(my $i=0; $i<4; $i++) { + &cleanup_script_database($d, $opts->{'db'}, "llx_"); + } # Take out the DB if ($opts->{'newdb'}) { diff --git a/dev/ansible/README.md b/dev/ansible/README.md deleted file mode 100644 index e498ebc3340..00000000000 --- a/dev/ansible/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# This directory contains script example to use ansible to deploy or maitains dolibarr instances - -This is a quick tutorial: - -* Install ansible: -> apt-get install ansible - -* Add ip of server to manage into -/etc/ansible/hosts - -* Deploy public key to managed servers -- authorized_key: user=charlie key="{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}" - - diff --git a/dev/ansible/deployplaybook/deploydev.yml b/dev/ansible/deployplaybook/deploydev.yml deleted file mode 100644 index 5802fb10a1e..00000000000 --- a/dev/ansible/deployplaybook/deploydev.yml +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ansible-playbook - -# Run script with ansible-playbook deploydev.yml -# or ./deploydev.yml - -- name: Configure webserver with apache - hosts: webservers - sudo: True - tasks: - - name: install apache - apt: name=apache update_cache=yes - - name: copy apache config file - copy: src=files/apachealias.conf dest=/etc/apache/conf.d/dolibarr_dev - #- name: enable configuration - # file: > - # dest=/etc/apache/sites-enabled/default - # src=/etc/apache/sites-available/default - # state=link - - name: copy info.html - template: src=templates/info.html.j2 dest=/var/www/dolibarr_dev/info.html - mode=0644 - - name: restart apache - service: name=apache state=restarted - diff --git a/dev/ansible/deployplaybook/files/apachealias.conf b/dev/ansible/deployplaybook/files/apachealias.conf deleted file mode 100644 index d801094af5a..00000000000 --- a/dev/ansible/deployplaybook/files/apachealias.conf +++ /dev/null @@ -1,2 +0,0 @@ - -Alias /dolibarr_dev /var/www/dolibarr diff --git a/dev/ansible/deployplaybook/hosts b/dev/ansible/deployplaybook/hosts deleted file mode 100644 index 99627faba2b..00000000000 --- a/dev/ansible/deployplaybook/hosts +++ /dev/null @@ -1,2 +0,0 @@ -[webservers] -testserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=22 diff --git a/dev/ansible/deployplaybook/templates/info.html.j2 b/dev/ansible/deployplaybook/templates/info.html.j2 deleted file mode 100644 index 66fac1c4deb..00000000000 --- a/dev/ansible/deployplaybook/templates/info.html.j2 +++ /dev/null @@ -1,10 +0,0 @@ - - - Page info ansible - - -

Apache, configured by Ansible

-

If you can see this, Ansible successfully installed apache.

-

{{ ansible_managed }}

- - \ No newline at end of file diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 83938b158e7..854e4a4fb47 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -222,10 +222,11 @@ class Skeleton_Class extends CommonObject * @param int $limit offset limit * @param int $offset offset limit * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) * * @return int <0 if KO, >0 if OK */ - public function fetchAll($sortorder, $sortfield, $limit, $offset, array $filter = array()) + public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND') { dol_syslog(__METHOD__, LOG_DEBUG); @@ -240,14 +241,19 @@ class Skeleton_Class extends CommonObject $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - $sqlwhere [] = ' AND ' . $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } } if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' AND ', $sqlwhere); + $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); + } + + if (!empty($sortfield)) { + $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder; + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } - $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ' ' . $this->db->plimit($limit + 1, $offset); - $this->lines = array(); $resql = $this->db->query($sql); diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index accbd6111c7..bff9dbe4265 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -145,6 +145,7 @@ if ($result) { print '' . $langs->trans("Addanaccount") . ''; print '' . $langs->trans("ImportAccount") . ''; + print '' . $langs->trans("CheckProductAccountancyCode") . ''; print '

'; print ''; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 43b8150d2f6..315c9f55325 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -1,10 +1,9 @@ +/* Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Alexandre Spangaro - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Ari Elbaz (elarifr) - + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2015 Ari Elbaz (elarifr) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,19 +20,19 @@ */ /** - * \file htdocs/accountancy/admin/productaccount.php - * \ingroup Accounting Expert - * \brief Onglet de gestion de parametrages des ventilations + * \file htdocs/accountancy/admin/productaccount.php + * \ingroup Accounting Expert + * \brief Onglet de gestion de parametrages des ventilations */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; // Langs $langs->load("companies"); @@ -41,383 +40,355 @@ $langs->load("compta"); $langs->load("main"); $langs->load("accountancy"); -// Search & action GETPOST +// search & action GETPOST $action = GETPOST('action'); $codeventil_buy = GETPOST('codeventil_buy', 'array'); $codeventil_sell = GETPOST('codeventil_sell', 'array'); -$mesCasesCochees = GETPOST('mesCasesCochees', 'array'); -$account_number_buy = GETPOST('account_number_buy'); +$chk_prod = GETPOST('chk_prod', 'array'); +$account_number_buy = GETPOST('account_number_buy'); $account_number_sell = GETPOST('account_number_sell'); -$changeaccount = GETPOST('changeaccount','array'); -$changeaccount_buy = GETPOST('changeaccount_buy','array'); -$changeaccount_sell = GETPOST('changeaccount_sell','array'); -$search_ref = GETPOST('search_ref','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); +$changeaccount = GETPOST('changeaccount', 'array'); +$changeaccount_buy = GETPOST('changeaccount_buy', 'array'); +$changeaccount_sell = GETPOST('changeaccount_sell', 'array'); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); +$btn_changeaccount = GETPOST('changeaccount'); +$btn_changetype = GETPOST('changetype'); -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); -if ($page < 0) $page = 0; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if ($page < 0) + $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; -//bug in page limit if ACCOUNTING_LIMIT_LIST_VENTILATION < $conf->liste_limit there is no pagination displayed ! +// bug in page limit if ACCOUNTING_LIMIT_LIST_VENTILATION < $conf->liste_limit there is no pagination displayed ! if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) && $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION >= $conf->liste_limit) { - $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; -//} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { -// $limit = $conf->liste_limit; + $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; + // } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { + // $limit = $conf->liste_limit; } else { - $limit = $conf->liste_limit; + $limit = $conf->liste_limit; } $offset = $limit * $page; -if (! $sortfield) $sortfield="p.ref"; -if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) + $sortfield = "p.ref"; +if (! $sortorder) + $sortorder = "ASC"; + + // sales or purchase +if ($action == 'update') { + if (! empty($btn_changetype)) { + $error = 0; + + $accounting_product_modes = array ( + 'ACCOUNTANCY_SELL', + 'ACCOUNTANCY_BUY' + ); + + $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); + + if (in_array($accounting_product_mode, $accounting_product_modes)) { + + if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { + $error ++; + } + } else { + $error ++; + } + } + + if (! empty($btn_changeaccount)) { + $msg = '
' . $langs->trans("Processing") . '...
'; + if (! empty($chk_prod)) { + + $accounting = new AccountingAccount($db); + + $msg .= '
' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '
'; + + $cpt = 0; + foreach ( $chk_prod as $productid ) { + + $accounting_account_id=GETPOST('codeventil_'.$productid); + + $result=$accounting->fetch($accounting_account_id,null,1); + if ($result<0) { + //setEventMessage(null, $accounting->errors,'errors'); + $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '
' . $sql . '
'; + } else { + + $sql = " UPDATE " . MAIN_DB_PREFIX . "product"; + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + $sql .= " SET accountancy_code_buy = " . $accounting->account_number; + } + if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { + $sql .= " SET accountancy_code_sell = " . $accounting->account_number; + } + $sql .= " WHERE rowid = " . $productid; + + dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG); + if ($db->query($sql)) { + $msg .= '
' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '
'; + } else { + $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $accounting->account_number . '
' . $sql . '
'; + } + } + + $cpt ++; + } + } else { + $msg .= '
' . $langs->trans("AnyLineVentilate") . '
'; + } + $msg .= '
' . $langs->trans("EndProcessing") . '
'; + + } +} // Security check if ($user->societe_id > 0) - accessforbidden(); -// TODO after adding menu -// if (! $user->rights->accounting->ventilation->dispatch) -// accessforbidden(); + accessforbidden(); + // TODO after adding menu + // if (! $user->rights->accounting->ventilation->dispatch) + // accessforbidden(); $form = new FormVentilation($db); -//Defaut AccountingAccount RowId Product / Service -//at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid -//so we need to get those default value rowid first +// Defaut AccountingAccount RowId Product / Service +// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid +// so we need to get those default value rowid first $accounting = new AccountingAccount($db); -//TODO: we should need to check if result is a really exist accountaccount rowid..... -$aarowid_servbuy = $accounting->fetch('', ACCOUNTING_SERVICE_BUY_ACCOUNT); -$aarowid_prodbuy = $accounting->fetch('', ACCOUNTING_PRODUCT_BUY_ACCOUNT); -$aarowid_servsell = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT); -$aarowid_prodsell = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT); +// TODO: we should need to check if result is a really exist accountaccount rowid..... +$aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); +$aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); +$aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); +$aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1); -$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); -$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_ref=''; - $search_label=''; - $search_desc=''; + $search_ref = ''; + $search_label = ''; + $search_desc = ''; } -//TODO: modify to update all selected product with a sell account -if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs->trans("Accountancy_code_sell")) { - $error = 0; - - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "product as p"; - $sql1 .= " SET p.accountancy_code_sell=" . $account_number_sell; - $sql1 .= ' WHERE p.rowid IN (' . implode(',', $changeaccount) . ')'; - - // Debug - // print_r ($sql1); - - dol_syslog('accountancy/customer/lines.php::changeaccount product sell sql= ' . $sql1); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessage($db->lasterror(), 'errors'); - } - if (! $error) { - $db->commit(); - setEventMessage($langs->trans('Save'), 'mesgs'); - } else { - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } -} - -//TODO: modify to update all selected product with a buy account -if (is_array($changeaccount) && count($changeaccount) > 0 && $action == $langs->trans("Accountancy_code_buy")) { - $error = 0; - - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "product as p"; - $sql1 .= " SET p.accountancy_code_buy=" . $account_number_buy; - $sql1 .= ' WHERE p.rowid IN (' . implode(',', $changeaccount) . ')'; - - // Debug - // print_r ($sql1); - - dol_syslog('accountancy/customer/lines.php::changeaccount product buy sql= ' . $sql1); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessage($db->lasterror(), 'errors'); - } - if (! $error) { - $db->commit(); - setEventMessage($langs->trans('Save'), 'mesgs'); - } else { - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } -} +// debug move header to top +llxHeader('', $langs->trans("Accounts")); /* * View */ -llxHeader('', $langs->trans("Accounts")); -// For updating account export print ''; + $(function () { + $(\'#select-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = true; + }); + }); + $(\'#unselect-all\').click(function(event) { + // Iterate each checkbox + $(\':checkbox\').each(function() { + this.checked = false; + }); + }); + }); + '; -//TODO For select box -print ''; - -/* - * Action - */ -//TODO -/* -if ($action == 'ventil') { - print '
' . $langs->trans("Processing") . '...
'; - if (! empty($codeventil_buy) && ! empty($mesCasesCochees)) { - if (! empty($codeventil_sell) && ! empty($mesCasesCochees)) { - - } else { - print '
' . $langs->trans("AnyLineVentilate") . '
'; - } - print '
' . $langs->trans("EndProcessing") . '
'; -} -*/ -//do we really need to exclude old product not tosell / tobuy ? -//$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type , p.tosell , p.tobuy "; -//$sql .= " WHERE p.accountancy_code_sell IS NULL AND p.tosell = 1 OR p.accountancy_code_buy IS NULL AND p.tobuy = 1"; -//$sql .= " WHERE p.accountancy_code_sell ='' AND p.tosell = 1 OR p.accountancy_code_buy ='' AND p.tobuy = 1"; -$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; +$sql = "SELECT p.rowid, p.ref , p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; -//$sql .= " , " . MAIN_DB_PREFIX . "accountingaccount as aa"; $sql .= " WHERE ("; -$sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; -//Search on correct pcg version $pcgver = $conf->global->CHARTOFACCOUNTS; -$sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN - (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - //(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))"; -$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN - (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; - //(SELECT account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa WHERE fk_pcg_version='PCG99-BASE'))"; + +IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { + $sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; + $sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; +} else { + $sql .= " p.accountancy_code_sell ='' OR p.accountancy_code_sell IS NULL "; + $sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN + (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accountingaccount as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; +} + $sql .= ")"; -//Add search filter like + +// Add search filter like if (strlen(trim($search_ref))) { - $sql .= " AND (p.ref like '" . $search_ref . "%')"; + $sql .= " AND (p.ref like '" . $search_ref . "%')"; } if (strlen(trim($search_label))) { - $sql .= " AND (p.label like '" . $search_label . "%')"; + $sql .= " AND (p.label like '" . $search_label . "%')"; } if (strlen(trim($search_desc))) { - $sql .= " AND (p.description like '%" . $search_desc . "%')"; + $sql .= " AND (p.description like '%" . $search_desc . "%')"; } -$sql.= $db->order($sortfield,$sortorder); +$sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); if ($result) { - $num_lines = $db->num_rows($result); - $i = 0; - -/* - - + $num_lines = $db->num_rows($result); + $i = 0; + + /* * View */ - print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); - - print '
 '; - print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder); - print '  '; - - -//DEBUG -//print $sql; - - print '
'; -// print ''; - - print '
' . $langs->trans("DescProductAccountingAccount") . '
'; - print ''; - print ''; - - print ''; - print ''; - print ''; - print '
'; - print '
' . $langs->trans("ChangeAccount") . '
'; - print $langs->trans("Accountancy_code_buy") . ': ' . $form->select_account($account_number_buy, 'account_number_buy', 1,'', 0, 1); - print '
'; - print '
'; - print '
' . $langs->trans("ChangeAccount") . '
'; - print $langs->trans("Accountancy_code_sell") . ': ' . $form->select_account($account_number_sell, 'account_number_sell', 1, '', 0, 1); - print '
'; - print '
'; - //TODO change button - print ''; - print '
'; - - print ''; - print ''; -// print ''; -// print ''; -// print ''; - 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 ''; - print ''; - print ''; - print ''; - print_liste_field_titre(''); -// print_liste_field_titre(''); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; -// print ''; - print ''; - - $var = true; - - - while ( $i < min($num_lines, 250) ) { - $obj = $db->fetch_object($result); - $var = ! $var; - - - $compta_prodsell = $obj->accountancy_code_sell; - if (empty($compta_prodsell)) { - if ($obj->product_type == 0) { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_prodsell; - } else { - $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodsell_id = $aarowid_servsell; - } - } - - - $compta_prodbuy = $obj->accountancy_code_buy; - if (empty($compta_prodbuy)) { - if ($obj->product_type == 0) { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_prodbuy; - } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_servbuy; - } - } - - - $product_static = new Product($db); - - print ""; -//debug -print ''; - - print ""; - print ""; - // Ref produit as link - $product_static->ref = $obj->ref; - $product_static->id = $obj->rowid; - $product_static->type = $obj->type; - print ''; - - print ''; -//TODO ADJUST DESCRIPTION SIZE -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; - print ''; - - //acountingaccount buy - print ''; -//TODO: replace by select -// print ''; - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - - //acountingaccount sel - print ''; - -//TODO: replace by select - //TODO: we shoul set a user defined value to adjust user square / wide screen size - //$trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; - print ''; - //action edit & select box - print ''; - print ''; - //Checkbox select - print ''; - - print ""; - $i ++; - } - - $db->free($result); + print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines); + + print ''; + print ''; + print ''; + + print '
' . $langs->trans("Ref") . '' . $langs->trans("Label") . '' . $langs->trans("Description") . '' . $langs->trans("Accountancy_code_buy") . '' . $langs->trans("Accountancy_code_buy_suggest") . '' . $langs->trans("Accountancy_code_sell") . '' . $langs->trans("Accountancy_code_sell_suggest") . '' . $langs->trans("Ventilate") . '
/'.'
%% '; - print ''; -// print ''; - print ' '; - print ''; -// print ''; - print ' 
Compte Suggeres compta_prodbuy=' . $compta_prodbuy . ' -- compta_prodbuy_id' . $compta_prodbuy_id . '-- compta_prodsell:' . $compta_prodsell . '-- compta_prodsell_id' . $compta_prodsell_id . '
'; - if ($product_static->id) - print $product_static->getNomUrl(1); - else - print '- '; - print '' . $obj->label . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; - print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1); - print '' . $obj->accountancy_code_sell . ''; - print $form->select_account($compta_prodsell_id, 'codeventil[]', 1); - print '' . $obj->rowid . ''; - print img_edit(); - print ''; - print '
'; + print ''; + print ''; + print "\n"; + print ''; + print '\n"; + print ''; + print '\n"; + + print "
' . $langs->trans('OptionMode') . '' . $langs->trans('Description') . '
' . $langs->trans('Accountancy_code_sell') . '' . nl2br($langs->trans('OptionModeProductSell')); + print "
' . $langs->trans('Accountancy_code_buy') . '' . nl2br($langs->trans('OptionModeProductBuy')) . "
\n"; + + print '
'; + + print "
\n"; + + if (! empty($msg)) { + print $msg; + } + + // print '' . $langs->trans("DescProductAccountingAccount") . ' '; + // print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "p.rowid", "", $param, '', $sortfield, $sortorder); + print '  '; + + print ''; + print ''; + 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); + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + $var = true; + + while ( $i < min($num_lines, 250) ) { + $obj = $db->fetch_object($result); + $var = ! $var; + + $compta_prodsell = $obj->accountancy_code_sell; + + if ($obj->product_type == 0) { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_prodsell; + } else { + $compta_prodsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodsell_id = $aarowid_servsell; + } + + $compta_prodbuy = $obj->accountancy_code_buy; + + if ($obj->product_type == 0) { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } + + $product_static = new Product($db); + + print ""; + + print ""; + print ""; + // Ref produit as link + $product_static->ref = $obj->ref; + $product_static->id = $obj->rowid; + $product_static->type = $obj->type; + print ''; + print ''; + // TODO ADJUST DESCRIPTION SIZE + // print ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size + $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32; + print ''; + + // acountingaccount buy + + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print ''; + // TODO: replace by select + // print ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size + // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } else { + + // acountingaccount sel + print ''; + // TODO: replace by select + // TODO: we shoul set a user defined value to adjust user square / wide screen size + // $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; + print ''; + } + + // Checkbox select + print ''; + + print ""; + $i ++; + } + print '
' . $langs->trans("Accountancy_code_buy") . ''; + print '' . $langs->trans("Accountancy_code_buy_suggest") . ''; + } else { + print '' . $langs->trans("Accountancy_code_sell") . ''; + print '' . $langs->trans("Accountancy_code_sell_suggest") . ''; + } + // print_liste_field_titre(''); + print '' . $langs->trans("Ventilate") . '
/' . '
 '; + print ''; + print ' '; + print ''; + print '
'; + if ($product_static->id) + print $product_static->getNomUrl(1); + else + print '- '; + print '' . dol_trunc($obj->label, 24) . '' . $obj->description . '' . nl2br(dol_trunc($obj->description, $trunclengh)) . '' . $obj->accountancy_code_buy . '' . $compta_prodbuy . ''; + print $form->select_account($compta_prodbuy_id, 'codeventil_'.$product_static->id, 1); + print '' . $obj->accountancy_code_sell . ''; + print $form->select_account($compta_prodsell_id, 'codeventil_'.$product_static->id, 1); + print ''; + print '
'; + print '
'; + print ''; + + $db->free($result); } else { -// print $db->error(); - dol_print_error($db); + dol_print_error($db); } -print ""; - llxFooter(); $db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 0c79820ea44..988eecfab84 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -65,8 +65,10 @@ class AccountingAccount extends CommonObject * @param string $account_number Account number * @return int <0 if KO, >0 if OK */ - function fetch($rowid = null, $account_number = null) + function fetch($rowid = null, $account_number = null, $limittocurentchart=0) { + global $conf; + if ($rowid || $account_number) { $sql = "SELECT rowid, datec, tms, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, fk_user_author, fk_user_modif, active"; $sql.= " FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE"; @@ -75,7 +77,9 @@ class AccountingAccount extends CommonObject } elseif ($account_number) { $sql .= " account_number = '" . $account_number . "'"; } - + if (!empty($limittocurentchart)) { + $sql .=' AND fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; + } dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -101,7 +105,8 @@ class AccountingAccount extends CommonObject return 0; } } else { - dol_print_error($this->db); + $this->error="Error " . $this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); } } return -1; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 11d69e3c7e6..ba7d35cee70 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -27,10 +27,13 @@ */ require '../../main.inc.php'; + +// Class require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +// Langs $langs->load("bills"); $langs->load("compta"); $langs->load("main"); @@ -38,23 +41,23 @@ $langs->load("accountancy"); $account_parent = GETPOST('account_parent'); $changeaccount = GETPOST('changeaccount'); +//Search Getpost $search_ref = GETPOST('search_ref','alpha'); $search_invoice = GETPOST('search_invoice','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); $search_amount = GETPOST('search_amount','alpha'); $search_account = GETPOST('search_account','alpha'); +$search_vat = GETPOST('search_vat','alpha'); +//Getpost Order and column and limit page $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); - -//if ($page == -1) { $page = 0; } if ($page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; -//$limit = $conf->liste_limit; if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; } else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) { @@ -62,19 +65,11 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { } else { $limit = $conf->liste_limit; } -//$offset = $conf->liste_limit * $page; $offset = $limit * $page; -// TODO : remove comment -//elarifr we can not use only -//$sql .= " ORDER BY l.rowid"; -// f.datef will order like FA08 FA09 FA10 FA05 FA06 FA07 FA04... -// f.facnumber will not order properly invoice / avoir / accompte you can have All AC then All AV and all FA -// l.rowid when an invoice is edited rowid are added at end of table & facturedet.rowid are not ordered -//if (! $sortfield) $sortfield="f.facnumber"; + if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; -//if (! $sortorder) $sortorder="DESC"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) { $sortorder = " DESC "; @@ -98,6 +93,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $search_desc=''; $search_amount=''; $search_account=''; + $search_vat=''; } if (is_array($changeaccount) && count($changeaccount) > 0) { @@ -181,6 +177,10 @@ if (strlen(trim($search_amount))) { if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } +if (strlen(trim($search_vat))) +{ + $sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; +} if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")"; } @@ -210,6 +210,7 @@ if ($result) { 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("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(''); print_liste_field_titre(''); @@ -222,6 +223,7 @@ if ($result) { print ''; print ''; print ''; + print '%'; print ''; print ' '; print ''; @@ -257,6 +259,7 @@ if ($result) { print '' . dol_trunc($objp->product_label, 24) . ''; print '' . nl2br(dol_trunc($objp->description, 32)) . ''; print '' . price($objp->total_ht) . ''; + print '' . price($objp->tva_tx) . ''; print '' . $codecompta . ''; print '' . $objp->rowid . ''; print ''; @@ -275,4 +278,4 @@ if ($result) { print ""; llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index d3a4547c38b..6d82c324fd6 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -24,14 +24,13 @@ * \ingroup Accounting Expert * \brief Ventilation page from customers invoices */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -42,24 +41,25 @@ $langs->load("accountancy"); $action = GETPOST('action'); -//Select Box +// Select Box $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); -//Search Getpost -$search_invoice = GETPOST('search_invoice','alpha'); -$search_ref = GETPOST('search_ref','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); -$search_amount = GETPOST('search_amount','alpha'); -$search_account = GETPOST('search_account','alpha'); -$search_vat = GETPOST('search_vat','alpha'); +// Search Getpost +$search_invoice = GETPOST('search_invoice', 'alpha'); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); -//Getpost Order and column and limit page -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page'); -if ($page < 0) $page = 0; +// Getpost Order and column and limit page +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page','int'); +if ($page < 0) + $page = 0; if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; @@ -70,7 +70,8 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { } $offset = $limit * $page; -if (! $sortfield) $sortfield="f.datef, f.facnumber, l.rowid"; +if (! $sortfield) + $sortfield = "f.datef, f.facnumber, l.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { @@ -91,23 +92,23 @@ $aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_SOLD_ACCOUNT); $aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_SOLD_ACCOUNT); // Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) -{ - $search_ref=''; - $search_invoice=''; - $search_label=''; - $search_desc=''; - $search_amount=''; - $search_account=''; - $search_vat=''; +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { + $search_ref = ''; + $search_invoice = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; } + /* * View */ llxHeader('', $langs->trans("Ventilation")); -print ''; -/* - * Action - */ /* * Supplier Invoice lines @@ -157,6 +179,10 @@ if (strlen(trim($search_amount))) { if (strlen(trim($search_account))) { $sql .= " AND aa.account_number like '%" . $search_account . "%'"; } +if (strlen(trim($search_vat))) +{ + $sql .= " AND (l.tva_tx like '" . $search_vat . "%')"; +} if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } @@ -187,6 +213,7 @@ if ($result) { 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("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(''); print_liste_field_titre(''); @@ -198,11 +225,12 @@ if ($result) { print ''; print ''; print ''; + print '%'; print ''; print ' '; - print ''; + print ''; print ''; - print "\n"; + print "\n"; $facturefournisseur_static = new FactureFournisseur($db); $product_static = new Product($db); @@ -234,6 +262,7 @@ if ($result) { print '' . dol_trunc($objp->product_label, 24) . ''; print '' . nl2br(dol_trunc($objp->description, 32)) . ''; print '' . price($objp->total_ht) . ''; + print '' . price($objp->tva_tx) . ''; print '' . $codeCompta . ''; print '' . $objp->rowid . ''; print ''; @@ -253,4 +282,4 @@ if ($result) { print ""; llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 2f22a19347a..b6e06209da1 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -24,14 +24,13 @@ * \ingroup Accounting Expert * \brief Ventilation page from suppliers invoices */ - require '../../main.inc.php'; // Class -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; // Langs $langs->load("compta"); @@ -41,18 +40,28 @@ $langs->load("main"); $langs->load("accountancy"); $action = GETPOST('action'); + +// Select Box $codeventil = GETPOST('codeventil', 'array'); $mesCasesCochees = GETPOST('mesCasesCochees', 'array'); -$search_ref = GETPOST('search_ref','alpha'); -$search_label = GETPOST('search_label','alpha'); -$search_desc = GETPOST('search_desc','alpha'); -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -//Should move to top with all GETPOST +// Search Getpost +$search_invoice = GETPOST('search_invoice', 'alpha'); +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_desc = GETPOST('search_desc', 'alpha'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_account = GETPOST('search_account', 'alpha'); +$search_vat = GETPOST('search_vat', 'alpha'); +$btn_ventil = GETPOST('ventil', 'alpha'); + +// Getpost Order and column and limit page +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); + $page = GETPOST('page'); -if ($page < 0) $page = 0; - +if ($page < 0) + $page = 0; if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; @@ -62,18 +71,9 @@ if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) { $limit = $conf->liste_limit; } $offset = $limit * $page; -//End Should move to top with all GETPOST - -// TODO : remove comment -//elarifr we can not use only -//$sql .= " ORDER BY l.rowid"; -// f.datef will order like FA08 FA09 FA10 FA05 FA06 FA07 FA04... -// f.ref will not order properly invoice / avoir / accompte you can have All AC then All AV and all FA -// l.rowid when an invoice is edited rowid are added at end of table & facturedet.rowid are not ordered -//if (! $sortfield) $sortfield="l.rowid"; -if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid"; -//if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) + $sortfield = "f.datef, f.ref, l.rowid"; if (! $sortorder) { if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) { $sortorder = " DESC "; @@ -88,21 +88,24 @@ if (! $user->rights->accounting->ventilation->dispatch) $formventilation = new FormVentilation($db); -//Defaut AccountingAccount RowId Product / Service -//at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid -//so we need to get those default value rowid first +// Defaut AccountingAccount RowId Product / Service +// at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid +// so we need to get those default value rowid first $accounting = new AccountingAccount($db); -//TODO: we should need to check if result is a really exist accountaccount rowid..... +// TODO: we should need to check if result is a really exist accountaccount rowid..... $aarowid_s = $accounting->fetch('', ACCOUNTING_SERVICE_BUY_ACCOUNT); $aarowid_p = $accounting->fetch('', ACCOUNTING_PRODUCT_BUY_ACCOUNT); // Purge search criteria if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { - $search_ref=''; - $search_label=''; - $search_desc=''; + $search_ref = ''; + $search_label = ''; + $search_desc = ''; + $search_amount = ''; + $search_account = ''; + $search_vat = ''; } /* @@ -110,10 +113,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both */ llxHeader('', $langs->trans("Ventilation")); -//debug -//print_r($aarowid_s); -//print_r($aarowid_p); -print ' -
+