Merge pull request #3376 from FHenry/develop_darkjeff
NEW : fix some feature on accountancy modules (devellop)
This commit is contained in:
commit
f98c61fc06
@ -145,6 +145,7 @@ if ($result) {
|
||||
|
||||
print '<a class="butAction" href="./card.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
|
||||
print '<a class="butAction" href="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
|
||||
print '<a class="butAction" href="./productaccount.php">' . $langs->trans("CheckProductAccountancyCode") . '</a>';
|
||||
print '<br/><br/>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
<?PHP
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -21,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 = '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (! empty($chk_prod)) {
|
||||
|
||||
$accounting = new AccountingAccount($db);
|
||||
|
||||
$msg .= '<div><font color="red">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
|
||||
|
||||
$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 .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
} 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 .= '<div><font color="green">' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
|
||||
} else {
|
||||
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $accounting->account_number . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
}
|
||||
}
|
||||
|
||||
$cpt ++;
|
||||
}
|
||||
} else {
|
||||
$msg .= '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
|
||||
}
|
||||
$msg .= '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 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 '<script type="text/javascript">
|
||||
function launch_export() {
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
|
||||
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
|
||||
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
|
||||
}
|
||||
</script>';
|
||||
$(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;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
//TODO For select box
|
||||
print '<script type="text/javascript">
|
||||
$(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;
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
//TODO
|
||||
/*
|
||||
if ($action == 'ventil') {
|
||||
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if (! empty($codeventil_buy) && ! empty($mesCasesCochees)) {
|
||||
if (! empty($codeventil_sell) && ! empty($mesCasesCochees)) {
|
||||
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("AnyLineVentilate") . '</font></div>';
|
||||
}
|
||||
print '<div><font color="red">' . $langs->trans("EndProcessing") . '</font></div>';
|
||||
}
|
||||
*/
|
||||
//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 '<td align="left"><b>' . $langs->trans("DescProductAccountingAccount") . '</b></td> ';
|
||||
print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"p.rowid","",$param,'',$sortfield,$sortorder);
|
||||
print ' ';
|
||||
|
||||
|
||||
//DEBUG
|
||||
//print $sql;
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post"><br />';
|
||||
// print '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr>';
|
||||
print '<td width="33%">';
|
||||
print '<div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br />';
|
||||
print $langs->trans("Accountancy_code_buy") . ': ' . $form->select_account($account_number_buy, 'account_number_buy', 1,'', 0, 1);
|
||||
print '<input type="submit" class="butAction" name="action" value="' . $langs->trans("Accountancy_code_buy") . '"/></div>';
|
||||
print '</td>';
|
||||
|
||||
print '<td width="33%">';
|
||||
print '<div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br />';
|
||||
print $langs->trans("Accountancy_code_sell") . ': ' . $form->select_account($account_number_sell, 'account_number_sell', 1, '', 0, 1);
|
||||
print '<input type="submit" class="butAction" name="action" value="' . $langs->trans("Accountancy_code_sell") . '"/></div>';
|
||||
print '</td>';
|
||||
print '<td width="33%">';
|
||||
//TODO change button
|
||||
print '<input type="button" class="button" style="float: right;" value="Renseigner les comptes comptables produits manquant" onclick="launch_export();" />';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
// print '<td align="left">' . $langs->trans("Ref") . '</td>';
|
||||
// print '<td align="left">' . $langs->trans("Label") . '</td>';
|
||||
// print '<td align="left">' . $langs->trans("Description") . '</td>';
|
||||
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 '<td align="left">' . $langs->trans("Accountancy_code_buy") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
|
||||
print '<td align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
|
||||
print_liste_field_titre('');
|
||||
// print_liste_field_titre('');
|
||||
print '<td align="center" colspan="2">' . $langs->trans("Ventilate") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>'.'</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">%<input type="text" class="flat" size="20" name="search_ref" value="' . $search_ref . '"></td>';
|
||||
print '<td class="liste_titre">%<input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="30" name="search_desc" value="' . $search_desc . '"></td>';
|
||||
|
||||
print '<td class="liste_titre" colspan="3"> </td>';
|
||||
print '<td align="right" colspan="4" class="liste_titre">';
|
||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
// print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print ' ';
|
||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
// print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
print '</td>';
|
||||
// print '<td class="liste_titre" colspan="2"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
$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 "<tr $bc[$var]>";
|
||||
//debug
|
||||
print '<td align="left" colspan="6">Compte Suggeres compta_prodbuy=' . $compta_prodbuy . ' -- compta_prodbuy_id' . $compta_prodbuy_id . '-- compta_prodsell:' . $compta_prodsell . '-- compta_prodsell_id' . $compta_prodsell_id . '</td>';
|
||||
|
||||
print "</tr>";
|
||||
print "<tr $bc[$var]>";
|
||||
// Ref produit as link
|
||||
$product_static->ref = $obj->ref;
|
||||
$product_static->id = $obj->rowid;
|
||||
$product_static->type = $obj->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print '- ';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">' . $obj->label . '</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 : 32;
|
||||
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
|
||||
|
||||
//acountingaccount buy
|
||||
print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
||||
//TODO: replace by select
|
||||
// print '<td align="left">' . $compta_prodbuy . '</td>';
|
||||
//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 '<td align="center">';
|
||||
print $form->select_account($compta_prodbuy_id, 'codeventil[]', 1);
|
||||
print '</td>';
|
||||
|
||||
//acountingaccount sel
|
||||
print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
||||
|
||||
//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 '<td align="center">';
|
||||
print $form->select_account($compta_prodsell_id, 'codeventil[]', 1);
|
||||
print '</td>';
|
||||
//action edit & select box
|
||||
print '<td align="center">' . $obj->rowid . '</td>';
|
||||
print '<td><a href="./card.php?id=' . $obj->rowid . '">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
//Checkbox select
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="changeaccount[]" value="' . $obj->rowid . '"/></td>';
|
||||
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
|
||||
$db->free($result);
|
||||
print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr ' . $bc[false] . '><td width="200"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('Accountancy_code_sell') . '</td>';
|
||||
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductSell'));
|
||||
print "</td></tr>\n";
|
||||
print '<tr ' . $bc[true] . '><td width="200"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('Accountancy_code_buy') . '</td>';
|
||||
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductBuy')) . "</td></tr>\n";
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="changetype"></div>';
|
||||
|
||||
print "<br>\n";
|
||||
|
||||
if (! empty($msg)) {
|
||||
print $msg;
|
||||
}
|
||||
|
||||
// print '<td align="left"><b>' . $langs->trans("DescProductAccountingAccount") . '</b></td> ';
|
||||
// print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "p.rowid", "", $param, '', $sortfield, $sortorder);
|
||||
print ' ';
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
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"], "l.description", "", $param, '', $sortfield, $sortorder);
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
print '<th align="left">' . $langs->trans("Accountancy_code_buy") . '</td>';
|
||||
print '<th align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
|
||||
} else {
|
||||
print '<th align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
|
||||
print '<th align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
|
||||
}
|
||||
// print_liste_field_titre('');
|
||||
print '<td align="center">' . $langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>' . '</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_ref" value="' . $search_ref . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="30" name="search_desc" value="' . $search_desc . '"></td>';
|
||||
|
||||
print '<td class="liste_titre" colspan="2"> </td>';
|
||||
print '<td align="right" class="liste_titre">';
|
||||
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
|
||||
print ' ';
|
||||
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$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 "<tr $bc[$var]>";
|
||||
|
||||
print "</tr>";
|
||||
print "<tr $bc[$var]>";
|
||||
// Ref produit as link
|
||||
$product_static->ref = $obj->ref;
|
||||
$product_static->id = $obj->rowid;
|
||||
$product_static->type = $obj->type;
|
||||
print '<td>';
|
||||
if ($product_static->id)
|
||||
print $product_static->getNomUrl(1);
|
||||
else
|
||||
print '- ';
|
||||
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 : 32;
|
||||
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
|
||||
|
||||
// acountingaccount buy
|
||||
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
||||
// TODO: replace by select
|
||||
// print '<td align="left">' . $compta_prodbuy . '</td>';
|
||||
// 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 '<td align="center">';
|
||||
print $form->select_account($compta_prodbuy_id, 'codeventil_'.$product_static->id, 1);
|
||||
print '</td>';
|
||||
} else {
|
||||
|
||||
// acountingaccount sel
|
||||
print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
||||
// 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 '<td align="center">';
|
||||
print $form->select_account($compta_prodsell_id, 'codeventil_'.$product_static->id, 1);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Checkbox select
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="chk_prod[]" value="' . $obj->rowid . '"/></td>';
|
||||
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
print '</table>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" name="changeaccount" value="' . $langs->trans("Change_Account") . '"></div>';
|
||||
print '</form>';
|
||||
|
||||
$db->free($result);
|
||||
} else {
|
||||
// print $db->error();
|
||||
dol_print_error($db);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print "</table></form>";
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -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;
|
||||
|
||||
@ -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 '<td class="liste_titre"><input type="text" class="flat" size="15" 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="center"><input type="text" class="flat" size="8" name="search_amount" value="' . $search_amount. '"></td>';
|
||||
print '<td class="liste_titre" align="center">%<input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
|
||||
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="15" name="search_account" value="' . $search_account . '"></td>';
|
||||
print '<td class="liste_titre" colspan="2"> </td>';
|
||||
print '<td class="liste_titre" align="center"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
@ -257,6 +259,7 @@ if ($result) {
|
||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
|
||||
print '<td align="right">' . price($objp->total_ht) . '</td>';
|
||||
print '<td align="center">' . price($objp->tva_tx) . '</td>';
|
||||
print '<td align="center">' . $codecompta . '</td>';
|
||||
print '<td align="right">' . $objp->rowid . '</td>';
|
||||
print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '">';
|
||||
@ -275,4 +278,4 @@ if ($result) {
|
||||
print "</table></form>";
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
$db->close();
|
||||
|
||||
@ -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 '<script type="text/javascript">
|
||||
print '<script type="text/javascript">
|
||||
$(function () {
|
||||
$(\'#select-all\').click(function(event) {
|
||||
// Iterate each checkbox
|
||||
@ -139,18 +140,18 @@ if ($action == 'ventil') {
|
||||
$monId = $maLigneCourante[0];
|
||||
$monNumLigne = $maLigneCourante[1];
|
||||
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
|
||||
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
|
||||
$sql .= " SET fk_code_ventilation = " . $monCompte;
|
||||
$sql .= " WHERE rowid = " . $monId;
|
||||
|
||||
|
||||
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
}
|
||||
|
||||
|
||||
$cpt ++;
|
||||
}
|
||||
} else {
|
||||
@ -163,7 +164,6 @@ if ($action == 'ventil') {
|
||||
* Customer Invoice lines
|
||||
*/
|
||||
|
||||
|
||||
$sql = "SELECT f.facnumber, f.rowid as facid, f.datef, f.type as ftype, l.fk_product, l.description, l.total_ht, l.rowid, l.fk_code_ventilation,";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod";
|
||||
$sql .= " , aa.rowid as aarowid";
|
||||
@ -177,8 +177,7 @@ $sql .= " WHERE f.fk_statut > 0 AND fk_code_ventilation <= 0";
|
||||
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')";
|
||||
|
||||
// Add search filter like
|
||||
if (strlen(trim($search_invoice)))
|
||||
{
|
||||
if (strlen(trim($search_invoice))) {
|
||||
$sql .= " AND (f.facnumber like '%" . $search_invoice . "%')";
|
||||
}
|
||||
if (strlen(trim($search_ref))) {
|
||||
@ -190,16 +189,13 @@ if (strlen(trim($search_label))) {
|
||||
if (strlen(trim($search_desc))) {
|
||||
$sql .= " AND (l.description like '%" . $search_desc . "%')";
|
||||
}
|
||||
if (strlen(trim($search_amount)))
|
||||
{
|
||||
if (strlen(trim($search_amount))) {
|
||||
$sql .= " AND l.total_ht like '" . $search_amount . "%'";
|
||||
}
|
||||
if (strlen(trim($search_account)))
|
||||
{
|
||||
if (strlen(trim($search_account))) {
|
||||
$sql .= " AND aa.account_number like '%" . $search_account . "%'";
|
||||
}
|
||||
if (strlen(trim($search_vat)))
|
||||
{
|
||||
if (strlen(trim($search_vat))) {
|
||||
$sql .= " AND (l.tva_tx like '" . $search_vat . "%')";
|
||||
}
|
||||
|
||||
@ -207,7 +203,7 @@ if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND f.entity IN (" . getEntity("facture", 1) . ")";
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
@ -216,87 +212,86 @@ $result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
|
||||
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
|
||||
print_liste_field_titre($langs->trans("Date"), $_SERVER["PHP_SELF"],"f.datef","",$param,'',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("Date"), $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder);
|
||||
print ' ';
|
||||
print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"],"l.rowid","",$param,'',$sortfield,$sortorder);
|
||||
|
||||
print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
||||
print '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"],"f.facnumber","",$param,'',$sortfield,$sortorder);
|
||||
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"),'','','','','align="right"');
|
||||
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"],"l.tva_tx","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans("AccountAccounting"),'','','','','align="center"');
|
||||
print_liste_field_titre($langs->trans("IntoAccount"),'','','','','align="center"');
|
||||
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
|
||||
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("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("AccountAccounting"), '', '', '', '', 'align="center"');
|
||||
print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"');
|
||||
print_liste_field_titre('');
|
||||
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>','','','','','align="center"');
|
||||
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"');
|
||||
print '</tr>';
|
||||
|
||||
// We add search filter
|
||||
|
||||
|
||||
// We add search filter
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>';
|
||||
print '<td class="liste_titre">%<input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>';
|
||||
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount. '"></td>';
|
||||
print '<td class="liste_titre" align="center">%<input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
|
||||
print '<td class="liste_titre" align="center"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td align="right" colspan="2" class="liste_titre">';
|
||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>';
|
||||
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
|
||||
print '<td align="right" class="liste_titre" colspan="4">';
|
||||
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
|
||||
print ' ';
|
||||
print '<input type="image" class="liste_titre" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
$facture_static = new Facture($db);
|
||||
$product_static = new Product($db);
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
$var = true;
|
||||
while ( $i < min($num_lines, $limit) ) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$var = ! $var;
|
||||
|
||||
|
||||
$objp->code_sell_l = '';
|
||||
$objp->code_sell_p = '';
|
||||
$objp->aarowid_suggest = '';
|
||||
$code_sell_p_l_differ = '';
|
||||
|
||||
|
||||
$code_sell_p_notset = '';
|
||||
$objp->aarowid_suggest = $objp->aarowid;
|
||||
if ( ! empty($objp->code_sell)) {
|
||||
if (! empty($objp->code_sell)) {
|
||||
$objp->code_sell_p = $objp->code_sell;
|
||||
} else {
|
||||
$code_sell_p_notset = 'color:red';
|
||||
if ($objp->type == 1) {
|
||||
$objp->code_sell_p = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
elseif ($objp->type == 0) {
|
||||
} elseif ($objp->type == 0) {
|
||||
$objp->code_sell_p = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
}
|
||||
if ($objp->type_l == 1) {
|
||||
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_s;
|
||||
}
|
||||
elseif ($objp->type_l == 0) {
|
||||
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p;
|
||||
}
|
||||
if ($objp->code_sell_l <> $objp->code_sell_p) $code_sell_p_l_differ = 'color:red';
|
||||
|
||||
if ($objp->type_l == 1) {
|
||||
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '')
|
||||
$objp->aarowid_suggest = $aarowid_s;
|
||||
} elseif ($objp->type_l == 0) {
|
||||
$objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '')
|
||||
$objp->aarowid_suggest = $aarowid_p;
|
||||
}
|
||||
if ($objp->code_sell_l != $objp->code_sell_p)
|
||||
$code_sell_p_l_differ = 'color:red';
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
|
||||
// Ref Invoice
|
||||
$facture_static->ref = $objp->facnumber;
|
||||
$facture_static->id = $objp->facid;
|
||||
@ -311,21 +306,25 @@ if ($result) {
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
|
||||
print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
|
||||
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>';
|
||||
print '<td align="right">';
|
||||
print price($objp->total_ht);
|
||||
print '</td>';
|
||||
if ($objp->vat_tx_l <> $objp->vat_tx_p) $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
|
||||
print '<td style="' . $code_vat_differ . '" align="center">';
|
||||
print price($objp->tva_tx_line);
|
||||
print '</td>';
|
||||
print '<td align="center" style="' . $code_sell_p_notset . '">';
|
||||
if ($objp->code_sell_l == $objp->code_sell_p) {
|
||||
print $objp->code_sell_l;
|
||||
} else {
|
||||
print 'lines='.$objp->code_sell_l . '<br />product=' . $objp->code_sell_p;
|
||||
print 'lines=' . $objp->code_sell_l . '<br />product=' . $objp->code_sell_p;
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
print '<td align="center">';
|
||||
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1);
|
||||
print '</td>';
|
||||
@ -336,7 +335,7 @@ if ($result) {
|
||||
print '</tr>';
|
||||
$i ++;
|
||||
}
|
||||
|
||||
|
||||
print '</table>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '"></div>';
|
||||
print '</form>';
|
||||
@ -345,4 +344,4 @@ if ($result) {
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
$db->close();
|
||||
@ -26,11 +26,14 @@
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
// Langs
|
||||
$langs->load("compta");
|
||||
$langs->load("bills");
|
||||
$langs->load("other");
|
||||
@ -39,24 +42,45 @@ $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;
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
$limit = $conf->liste_limit;
|
||||
if (! $sortfield) $sortfield="f.ref";
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION))
|
||||
{
|
||||
$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;
|
||||
}
|
||||
if (! $sortfield) $sortfield="f.datef, f.ref, l.rowid";
|
||||
|
||||
if (! $sortorder)
|
||||
{
|
||||
if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0)
|
||||
{
|
||||
$sortorder = " DESC ";
|
||||
}
|
||||
}
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
@ -75,6 +99,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) {
|
||||
@ -124,9 +149,6 @@ print '<script type="text/javascript">
|
||||
});
|
||||
</script>';
|
||||
|
||||
/*
|
||||
* 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 '<td class="liste_titre"><input type="text" class="flat" size="15" 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="center"><input type="text" class="flat" size="8" name="search_amount" value="' . $search_amount . '"></td>';
|
||||
print '<td class="liste_titre" align="center">%<input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
|
||||
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="15" name="search_account" value="' . $search_account . '"></td>';
|
||||
print '<td class="liste_titre" colspan="2"> </td>';
|
||||
print '<td class="liste_titre" align="center"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print '<td class="liste_titre" align="center"><input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
|
||||
print "</td></tr>\n";
|
||||
print "</td></tr>\n";
|
||||
|
||||
$facturefournisseur_static = new FactureFournisseur($db);
|
||||
$product_static = new Product($db);
|
||||
@ -234,6 +262,7 @@ if ($result) {
|
||||
print '<td>' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
print '<td>' . nl2br(dol_trunc($objp->description, 32)) . '</td>';
|
||||
print '<td align="right">' . price($objp->total_ht) . '</td>';
|
||||
print '<td align="center">' . price($objp->tva_tx) . '</td>';
|
||||
print '<td align="center">' . $codeCompta . '</td>';
|
||||
print '<td align="right">' . $objp->rowid . '</td>';
|
||||
print '<td align="left"><a href="./card.php?id=' . $objp->rowid . '">';
|
||||
@ -253,4 +282,4 @@ if ($result) {
|
||||
print "</table></form>";
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
$db->close();
|
||||
|
||||
@ -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 '<script type="text/javascript">
|
||||
print '<script type="text/javascript">
|
||||
$(function () {
|
||||
$(\'#select-all\').click(function(event) {
|
||||
// Iterate each checkbox
|
||||
@ -133,31 +133,31 @@ print '<script type="text/javascript">
|
||||
* Action
|
||||
*/
|
||||
|
||||
if ($action == 'ventil') {
|
||||
if ($action == 'ventil' && !empty($btn_ventil)) {
|
||||
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
|
||||
if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) {
|
||||
print '<div><font color="red">' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
|
||||
$mesCodesVentilChoisis = $codeventil;
|
||||
$cpt = 0;
|
||||
|
||||
|
||||
foreach ( $mesCasesCochees as $maLigneCochee ) {
|
||||
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
|
||||
$maLigneCourante = explode("_", $maLigneCochee);
|
||||
$monId = $maLigneCourante[0];
|
||||
$monNumLigne = $maLigneCourante[1];
|
||||
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
|
||||
|
||||
|
||||
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = " . $monCompte;
|
||||
$sql .= " WHERE rowid = " . $monId;
|
||||
|
||||
|
||||
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
|
||||
if ($db->query($sql)) {
|
||||
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
|
||||
} else {
|
||||
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
|
||||
}
|
||||
|
||||
|
||||
$cpt ++;
|
||||
}
|
||||
} else {
|
||||
@ -170,22 +170,9 @@ if ($action == 'ventil') {
|
||||
* Supplier Invoice Lines
|
||||
*
|
||||
*/
|
||||
$page = GETPOST('page');
|
||||
if ($page < 0)
|
||||
$page = 0;
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
|
||||
$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;
|
||||
}
|
||||
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, ";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy";
|
||||
$sql = "SELECT f.ref, f.rowid as facid, f.ref_supplier, l.fk_product, l.description, l.total_ht as price, l.rowid, l.fk_code_ventilation, l.tva_tx as tva_tx_line, ";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod";
|
||||
$sql .= " , aa.rowid as aarowid";
|
||||
$sql .= " , f.datef";
|
||||
$sql .= " , l.product_type as type_l";
|
||||
@ -195,9 +182,12 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON p.accountancy_code_buy = aa.account_number";
|
||||
$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 fk_code_ventilation <= 0";
|
||||
$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_sell IS NULL OR p.accountancy_code_buy ='')";
|
||||
|
||||
// Add search filter like
|
||||
if (strlen(trim($search_invoice))) {
|
||||
$sql .= " AND (f.ref like '%" . $search_invoice . "%')";
|
||||
}
|
||||
if (strlen(trim($search_ref))) {
|
||||
$sql .= " AND (p.ref like '%" . $search_ref . "%')";
|
||||
}
|
||||
@ -207,11 +197,20 @@ if (strlen(trim($search_label))) {
|
||||
if (strlen(trim($search_desc))) {
|
||||
$sql .= " AND (l.description like '%" . $search_desc . "%')";
|
||||
}
|
||||
if (strlen(trim($search_amount))) {
|
||||
$sql .= " AND l.total_ht like '" . $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) . ")";
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield,$sortorder);
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
@ -220,32 +219,49 @@ $result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num_lines = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
|
||||
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
|
||||
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
||||
|
||||
|
||||
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
|
||||
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
|
||||
print '<input type="hidden" name="action" value="ventil">';
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"],"f.ref","",$param,'',$sortfield,$sortorder);
|
||||
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"),'','','','','align="right"');
|
||||
print_liste_field_titre($langs->trans("AccountAccounting"),'','','','','align="center"');
|
||||
print_liste_field_titre($langs->trans("IntoAccount"),'','','','','align="center"');
|
||||
print_liste_field_titre('');
|
||||
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">'.$langs->trans('All').'</label>/<label id="unselect-all">'.$langs->trans('None').'</label>','','','','','align="center"');
|
||||
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
|
||||
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("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("AccountAccounting"), '', '', '', '', 'align="center"');
|
||||
print_liste_field_titre($langs->trans("IntoAccount"), '', '', '', '', 'align="center"');
|
||||
print_liste_field_titre('');
|
||||
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"');
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>';
|
||||
print '<td class="liste_titre">%<input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>';
|
||||
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>';
|
||||
print '<td class="liste_titre" align="center">%<input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '"></td>';
|
||||
print '<td class="liste_titre" align="center"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td align="right" colspan="2" class="liste_titre">';
|
||||
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
|
||||
print ' ';
|
||||
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$facturefourn_static = new FactureFournisseur($db);
|
||||
$productfourn_static = new ProductFournisseur($db);
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
$var = True;
|
||||
while ( $i < min($num_lines, $limit) ) {
|
||||
$objp = $db->fetch_object($result);
|
||||
@ -258,43 +274,43 @@ if ($result) {
|
||||
$objp->code_buy_p = '';
|
||||
$objp->aarowid_suggest = '';
|
||||
$code_buy_p_l_differ = '';
|
||||
|
||||
|
||||
$code_buy_p_notset = '';
|
||||
|
||||
|
||||
$objp->aarowid_suggest = $objp->aarowid;
|
||||
if ( ! empty($objp->code_buy)) {
|
||||
if (! empty($objp->code_buy)) {
|
||||
$objp->code_buy_p = $objp->code_buy;
|
||||
} else {
|
||||
$code_buy_p_notset = 'color:red';
|
||||
if ($objp->type == 1) {
|
||||
$objp->code_buy_p = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
elseif ($objp->type == 0) {
|
||||
$objp->code_buy_p = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
}
|
||||
}
|
||||
|
||||
if ($objp->type_l == 1) {
|
||||
$objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_s;
|
||||
}
|
||||
elseif ($objp->type_l == 0) {
|
||||
$objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '') $objp->aarowid_suggest = $aarowid_p;
|
||||
}
|
||||
if ($objp->type_l == 1) {
|
||||
$objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '')
|
||||
$objp->aarowid_suggest = $aarowid_s;
|
||||
} elseif ($objp->type_l == 0) {
|
||||
$objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
if ($objp->aarowid == '')
|
||||
$objp->aarowid_suggest = $aarowid_p;
|
||||
}
|
||||
|
||||
if ($objp->code_buy_l <> $objp->code_buy_p) $code_buy_p_l_differ = 'color:red';
|
||||
if ($objp->code_buy_l != $objp->code_buy_p)
|
||||
$code_buy_p_l_differ = 'color:red';
|
||||
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
|
||||
// Ref Invoice
|
||||
$facturefourn_static->ref = $objp->ref;
|
||||
$facturefourn_static->id = $objp->facid;
|
||||
print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>';
|
||||
|
||||
|
||||
// Ref Supplier Invoice
|
||||
$productfourn_static->ref = $objp->product_ref;
|
||||
$productfourn_static->id = $objp->product_id;
|
||||
@ -305,26 +321,32 @@ if ($result) {
|
||||
else
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
|
||||
print '<td style="' . $code_buy_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>';
|
||||
|
||||
|
||||
// TODO: we should set a user defined value to adjust user square / wide screen size
|
||||
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
|
||||
print '<td style="' . $code_buy_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>';
|
||||
|
||||
|
||||
print '<td align="right">';
|
||||
print price($objp->price);
|
||||
print '</td>';
|
||||
|
||||
|
||||
if ($objp->vat_tx_l != $objp->vat_tx_p)
|
||||
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
|
||||
print '<td style="' . $code_vat_differ . '" align="center">';
|
||||
print price($objp->tva_tx_line);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center" style="' . $code_buy_p_notset . '">';
|
||||
//if not same kind of product_type stored in product & facturedt we display both account and let user choose
|
||||
// if not same kind of product_type stored in product & facturedt we display both account and let user choose
|
||||
if ($objp->code_buy_l == $objp->code_buy_p) {
|
||||
print $objp->code_buy_l;
|
||||
} else {
|
||||
print 'lines='.$objp->code_buy_l . '<br />product=' . $objp->code_buy_p;
|
||||
print 'lines=' . $objp->code_buy_l . '<br />product=' . $objp->code_buy_p;
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
||||
// Colonne choix du compte
|
||||
print '<td align="center">';
|
||||
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1);
|
||||
@ -332,19 +354,19 @@ if ($result) {
|
||||
print '<td align="center">' . $objp->rowid . '</td>';
|
||||
// Colonne choix ligne a ventiler
|
||||
print '<td align="center">';
|
||||
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid_suggest ? "checked" : "") . '/>';
|
||||
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
|
||||
print '</td>';
|
||||
|
||||
|
||||
print "</tr>";
|
||||
$i ++;
|
||||
}
|
||||
|
||||
|
||||
print '</table>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '"></div>';
|
||||
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil" ></div>';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $db->error();
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
$db->close();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user