commit
e9f9b5bdf4
@ -429,4 +429,158 @@ class AccountancyCategory
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCats() {
|
||||
global $db, $langs, $user, $mysoc;
|
||||
|
||||
if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
|
||||
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (! empty($mysoc->country_id)) {
|
||||
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c";
|
||||
$sql .= " WHERE c.active = 1 ";
|
||||
$sql .= " AND c.fk_country = " . $mysoc->country_id;
|
||||
$sql .= " ORDER BY c.position ASC";
|
||||
} else {
|
||||
$sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c, " . MAIN_DB_PREFIX . "c_country as co";
|
||||
$sql .= " WHERE c.active = 1 AND c.fk_country = co.rowid";
|
||||
$sql .= " AND co.code = '" . $mysoc->country_code . "'";
|
||||
$sql .= " ORDER BY c.position ASC";
|
||||
}
|
||||
|
||||
dol_syslog(__METHOD__ . " sql=" . $sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$obj = '';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$data = array ();
|
||||
if ($num) {
|
||||
while ( $i < $num ) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$data[] = array (
|
||||
'rowid' => $obj->rowid,
|
||||
'code' => $obj->code,
|
||||
'position' => $obj->position,
|
||||
'label' => $obj->label,
|
||||
'formula' => $obj->formula,
|
||||
'category_type' => $obj->category_type
|
||||
);
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog(__METHOD__ . " " . implode(',', $this->errors), LOG_ERR);
|
||||
|
||||
return - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// calcule
|
||||
|
||||
const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/';
|
||||
|
||||
const PARENTHESIS_DEPTH = 10;
|
||||
|
||||
public function calculate($input){
|
||||
if(strpos($input, '+') != null || strpos($input, '-') != null || strpos($input, '/') != null || strpos($input, '*') != null){
|
||||
// Remove white spaces and invalid math chars
|
||||
$input = str_replace(',', '.', $input);
|
||||
$input = preg_replace('[^0-9\.\+\-\*\/\(\)]', '', $input);
|
||||
|
||||
// Calculate each of the parenthesis from the top
|
||||
$i = 0;
|
||||
while(strpos($input, '(') || strpos($input, ')')){
|
||||
$input = preg_replace_callback('/\(([^\(\)]+)\)/', 'self::callback', $input);
|
||||
|
||||
$i++;
|
||||
if($i > self::PARENTHESIS_DEPTH){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the result
|
||||
if(preg_match(self::PATTERN, $input, $match)){
|
||||
return $this->compute($match[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
private function compute($input){
|
||||
$compute = create_function('', 'return '.$input.';');
|
||||
|
||||
return 0 + $compute();
|
||||
}
|
||||
|
||||
private function callback($input){
|
||||
if(is_numeric($input[1])){
|
||||
return $input[1];
|
||||
}
|
||||
elseif(preg_match(self::PATTERN, $input[1], $match)){
|
||||
return $this->compute($match[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get cpts of category
|
||||
*
|
||||
* @return array Result in table
|
||||
*/
|
||||
public function getCptsCat($cat_id) {
|
||||
global $mysoc;
|
||||
$sql = "";
|
||||
|
||||
if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
|
||||
dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined');
|
||||
exit();
|
||||
}
|
||||
|
||||
$sql = "SELECT t.rowid, t.account_number, t.label as name_cpt";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
|
||||
$sql .= " WHERE t.fk_accounting_category = ".$cat_id;
|
||||
$sql .= " ORDER BY t.account_number ";
|
||||
|
||||
//echo $sql;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$obj = '';
|
||||
$num = $this->db->num_rows($resql);
|
||||
$data = array ();
|
||||
if ($num) {
|
||||
while ( $obj = $this->db->fetch_object($resql) ) {
|
||||
$name_cat = $obj->name_cat;
|
||||
$data[] = array (
|
||||
'id' => $obj->rowid,
|
||||
'account_number' => $obj->account_number,
|
||||
'name_cpt' => $obj->name_cpt,
|
||||
);
|
||||
$i ++;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
} else {
|
||||
$this->error = "Error " . $this->db->lasterror();
|
||||
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -738,7 +738,7 @@ if (empty($action) || $action == 'view') {
|
||||
$builddate = time();
|
||||
//$description = $langs->trans("DescFinanceJournal") . '<br>';
|
||||
$description.= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
|
||||
@ -489,7 +489,7 @@ if (empty($action) || $action == 'view') {
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
}
|
||||
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
|
||||
@ -505,7 +505,7 @@ if (empty($action) || $action == 'view') {
|
||||
$description .= $langs->trans("DepositsAreNotIncluded");
|
||||
else
|
||||
$description .= $langs->trans("DepositsAreIncluded");
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
|
||||
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1). ' - ' .$langs->trans("AlreadyInGeneralLedger").' '. $form->selectyesno('in_bookkeeping',$in_bookkeeping,0);
|
||||
|
||||
$varlink = 'id_journal=' . $id_journal;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
|
||||
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
/* Copyright (C) 2016/17 Jamal Elbaz <jamelbaz@gmail.com>
|
||||
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -25,6 +25,7 @@ require '../../main.inc.php';
|
||||
|
||||
// Class
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancycategory.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
|
||||
|
||||
@ -35,12 +36,14 @@ $langs->load("accountancy");
|
||||
$langs->load("compta");
|
||||
|
||||
$mesg = '';
|
||||
$action = GETPOST('action','aZ09');
|
||||
$action = GETPOST('action');
|
||||
$cat_id = GETPOST('account_category');
|
||||
$selectcpt = GETPOST('cpt_bk');
|
||||
$id = GETPOST('id', 'int');
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
$cancel = GETPOST('cancel');
|
||||
$simple_report = GETPOST('simple_report');
|
||||
|
||||
|
||||
// Filter
|
||||
$year = GETPOST('year','int');
|
||||
@ -77,7 +80,16 @@ $form = new Form($db);
|
||||
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>';
|
||||
$textnextyear = ' <a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans('ReportInOut'), $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear, 'title_accountancy');
|
||||
$nom = $langs->trans("ReportInOut");
|
||||
$nomlink = '';
|
||||
$periodlink = '';
|
||||
$exportlink = '';
|
||||
$builddate = time();
|
||||
$description = '';
|
||||
$period = $langs->trans("Detail").' '. $form->selectyesno('simple_report',$simple_report,0) . " " .$textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear ;
|
||||
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array (
|
||||
'action' => ''
|
||||
));
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
@ -108,37 +120,97 @@ foreach($months as $k => $v){
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
$cats = $AccCat->getCatsCpts();
|
||||
if ($cats < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
|
||||
|
||||
$catsCalcule = $AccCat->getCatsCal();
|
||||
|
||||
//All categories
|
||||
$cats = $AccCat->getCats();
|
||||
if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
|
||||
|
||||
$j=1;
|
||||
$sommes = array();
|
||||
|
||||
if (!empty($cats))
|
||||
{
|
||||
foreach ($cats as $name_cat => $cpts)
|
||||
{
|
||||
foreach($cats as $cat ){
|
||||
if(!empty($cat['category_type'])){ // category calculed
|
||||
|
||||
$formula = $cat['formula'];
|
||||
|
||||
print "<tr class='liste_titre'>";
|
||||
print '<td colspan="17">' . $name_cat . '</td>';
|
||||
print '<td colspan="2">' . $cat['label'] . '</td>';
|
||||
|
||||
$vars = array();
|
||||
|
||||
// Previous Fiscal year (N-1)
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['NP'];
|
||||
}
|
||||
|
||||
|
||||
$result = strtr($formula, $vars);
|
||||
|
||||
|
||||
$r = $AccCat->calculate($result);
|
||||
|
||||
print '<td align="right"><font color="blue">' . price($r) . '</td>';
|
||||
$code = $cat['code']; // code categorie de calcule
|
||||
$sommes[$code]['NP'] += $r;
|
||||
|
||||
// Current fiscal year (N)
|
||||
if (is_array($sommes) && ! empty($sommes)){
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['N'];
|
||||
}
|
||||
}
|
||||
|
||||
$result = strtr($formula, $vars);
|
||||
|
||||
$r = $AccCat->calculate($result);
|
||||
|
||||
print '<td align="right"><font color="blue">' . price($r) . '</td>';
|
||||
$sommes[$code]['N'] += $r;
|
||||
|
||||
// Detail by month
|
||||
foreach($months as $k => $v){
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['M'][$k];
|
||||
}
|
||||
$result = strtr($formula, $vars);
|
||||
$r = $AccCat->calculate($result);
|
||||
print '<td align="right"><font color="blue">' . price($r) . '</td>';
|
||||
$sommes[$code]['M'][$k] += $r;
|
||||
}
|
||||
|
||||
|
||||
print "</tr>\n";
|
||||
$position = -1;
|
||||
$code = -1;
|
||||
|
||||
|
||||
}else{ // normal category
|
||||
|
||||
$totCat = array();
|
||||
$totCat['M'] = array();
|
||||
|
||||
// get cpts of category
|
||||
$cpts = $AccCat->getCptsCat($cat['rowid']);
|
||||
|
||||
|
||||
print "<tr class='liste_titre'>";
|
||||
print '<td colspan="2">' . $cat['label'] . '</td>';
|
||||
|
||||
foreach($cpts as $i => $cpt){
|
||||
$var = ! $var;
|
||||
|
||||
$position = $cpt['position'];
|
||||
$code = $cpt['code'];
|
||||
|
||||
$code = $cat['code'];
|
||||
|
||||
// N-1
|
||||
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
|
||||
|
||||
if ($return < 0) {
|
||||
setEventMessages(null, $AccCat->errors, 'errors');
|
||||
$resultNP=0;
|
||||
} else {
|
||||
$resultNP=$AccCat->sdc;
|
||||
}
|
||||
|
||||
|
||||
//N
|
||||
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
|
||||
if ($return < 0) {
|
||||
setEventMessages(null, $AccCat->errors, 'errors');
|
||||
@ -146,13 +218,64 @@ if (!empty($cats))
|
||||
} else {
|
||||
$resultN=$AccCat->sdc;
|
||||
}
|
||||
|
||||
$totCat['NP'] += $resultNP;
|
||||
$totCat['N'] += $resultN;
|
||||
|
||||
foreach($months as $k => $v){
|
||||
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
|
||||
if ($return < 0) {
|
||||
setEventMessages(null, $AccCat->errors, 'errors');
|
||||
$resultM=0;
|
||||
} else {
|
||||
$resultM=$AccCat->sdc;
|
||||
}
|
||||
$totCat['M'][$k] += $resultM;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
print '<td align="right">' . price($totCat['NP']) . '</td>';
|
||||
print '<td align="right">' . price($totCat['N']) . '</td>';
|
||||
|
||||
foreach($totCat['M'] as $k => $v){
|
||||
print '<td align="right">' . price($v) . '</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
foreach($cpts as $i => $cpt){
|
||||
$var = ! $var;
|
||||
|
||||
$code = $cat['code'];
|
||||
|
||||
// N-1
|
||||
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']);
|
||||
|
||||
if ($return < 0) {
|
||||
setEventMessages(null, $AccCat->errors, 'errors');
|
||||
$resultNP=0;
|
||||
} else {
|
||||
$resultNP=$AccCat->sdc;
|
||||
}
|
||||
|
||||
//N
|
||||
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']);
|
||||
if ($return < 0) {
|
||||
setEventMessages(null, $AccCat->errors, 'errors');
|
||||
$resultN=0;
|
||||
} else {
|
||||
$resultN=$AccCat->sdc;
|
||||
}
|
||||
|
||||
$sommes[$code]['NP'] += $resultNP;
|
||||
$sommes[$code]['N'] += $resultN;
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>' . $cpt['account_number'] . '</td>';
|
||||
print '<tr'. $bc[$var].'>';
|
||||
if ($simple_report == 'yes') {
|
||||
print '<td>' . length_accountg($cpt['account_number']) . '</td>';
|
||||
print '<td>' . $cpt['name_cpt'] . '</td>';
|
||||
print '<td>' . price($resultNP) . '</td>';
|
||||
print '<td>' . price($resultN) . '</td>';
|
||||
print '<td align="right">' . price($resultNP) . '</td>';
|
||||
print '<td align="right">' . price($resultN) . '</td>';
|
||||
}
|
||||
|
||||
foreach($months as $k => $v){
|
||||
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']);
|
||||
@ -163,102 +286,15 @@ if (!empty($cats))
|
||||
$resultM=$AccCat->sdc;
|
||||
}
|
||||
$sommes[$code]['M'][$k] += $resultM;
|
||||
if ($simple_report == 'yes') {
|
||||
print '<td align="right">' . price($resultM) . '</td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
// If it's a calculated catgory
|
||||
$p = $position + 1;
|
||||
if(array_key_exists($p, $catsCalcule)){
|
||||
$formula = $catsCalcule[$p]['formula'];
|
||||
|
||||
print "<tr class='liste_titre'>";
|
||||
print '<td colspan="2">' . $catsCalcule[$p]['label'] . '</td>';
|
||||
|
||||
$vars = array();
|
||||
|
||||
// Previous Fiscal year (N-1)
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['NP'];
|
||||
}
|
||||
$result = strtr($formula, $vars);
|
||||
eval( '$result = (' . $result . ');' );
|
||||
print '<td align="right">' . price($result) . '</td>';
|
||||
$code = $catsCalcule[$p]['code']; // code categorie de calcule
|
||||
$sommes[$code]['NP'] += $result;
|
||||
|
||||
// Current fiscal year (N)
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['N'];
|
||||
}
|
||||
$result = strtr($formula, $vars);
|
||||
eval( '$result = (' . $result . ');' );
|
||||
print '<td align="right">' . price($result) . '</td>';
|
||||
$sommes[$code]['N'] += $result;
|
||||
|
||||
// Detail by month
|
||||
foreach($months as $k => $v){
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['M'][$k];
|
||||
}
|
||||
$result = strtr($formula, $vars);
|
||||
eval( '$result = (' . $result . ');' );
|
||||
print '<td align="right">' . price($result) . '</td>';
|
||||
$sommes[$code]['M'][$k] += $result;
|
||||
}
|
||||
|
||||
//print '<td colspan="15">' . $catsCalcule[$p]['formula'] . '</td>';
|
||||
print "</tr>\n";
|
||||
unset($catsCalcule[$p]); // j'élimine la catégorie calculée après affichage
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
// Others calculed category
|
||||
foreach($catsCalcule as $p => $catc)
|
||||
{
|
||||
$formula = $catsCalcule[$p]['formula'];
|
||||
|
||||
print "<tr class='liste_titre'>";
|
||||
print '<td colspan="2">' . $catsCalcule[$p]['label'] . '</td>';
|
||||
|
||||
$vars = array();
|
||||
|
||||
// Previous Fiscal year (N-1)
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['NP'];
|
||||
}
|
||||
$result = strtr($formula, $vars);
|
||||
eval( '$result = (' . $result . ');' );
|
||||
print '<td align="right">' . price($result) . '</td>';
|
||||
$code = $catsCalcule[$p]['code']; // code categorie de calcule
|
||||
$sommes[$code]['NP'] += $result;
|
||||
|
||||
// Current fiscal year (N)
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['N'];
|
||||
}
|
||||
$result = strtr($formula, $vars);
|
||||
eval( '$result = (' . $result . ');' );
|
||||
print '<td align="right">' . price($result) . '</td>';
|
||||
$sommes[$code]['N'] += $result;
|
||||
|
||||
// Detail by month
|
||||
foreach($months as $k => $v){
|
||||
foreach($sommes as $code => $det){
|
||||
$vars[$code] = $det['M'][$k];
|
||||
}
|
||||
$result = strtr($formula, $vars);
|
||||
eval( '$result = (' . $result . ');' );
|
||||
print '<td align="right">' . price($result) . '</td>';
|
||||
$sommes[$code]['M'][$k] += $result;
|
||||
}
|
||||
|
||||
//print '<td colspan="15">' . $catsCalcule[$p]['formula'] . '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
@ -52,6 +52,8 @@ $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_country = GETPOST('search_country', 'alpha');
|
||||
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
|
||||
@ -94,6 +96,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
|
||||
$search_amount = '';
|
||||
$search_account = '';
|
||||
$search_vat = '';
|
||||
$search_country = '';
|
||||
$search_tvaintra = '';
|
||||
}
|
||||
|
||||
if (is_array($changeaccount) && count($changeaccount) > 0) {
|
||||
@ -149,13 +153,15 @@ print '<script type="text/javascript">
|
||||
/*
|
||||
* Supplier Invoice lines
|
||||
*/
|
||||
$sql = "SELECT f.rowid as facid, f.ref as facnumber, f.ref_supplier, f.libelle as invoice_label, f.datef,";
|
||||
$sql = "SELECT f.rowid as facid, f.ref as facnumber, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
|
||||
$sql.= " l.rowid, l.fk_product, l.description, l.total_ht , l.qty, l.tva_tx, aa.label, aa.account_number, ";
|
||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
|
||||
$sql.= " , " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||
$sql.= " , " . MAIN_DB_PREFIX . "facture_fourn_det as l";
|
||||
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, co.label as country, s.tva_intra";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as l";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn";
|
||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as co ON co.rowid = s.fk_pays ";
|
||||
$sql.= " WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
|
||||
$sql.= " AND aa.rowid = l.fk_code_ventilation";
|
||||
if ($search_lineid) {
|
||||
@ -182,6 +188,12 @@ if (strlen(trim($search_account))) {
|
||||
if (strlen(trim($search_vat))) {
|
||||
$sql .= natural_search("l.tva_tx", $search_vat, 1);
|
||||
}
|
||||
if (strlen(trim($search_country))) {
|
||||
$sql .= " AND (co.label like'" . $search_country . "%')";
|
||||
}
|
||||
if (strlen(trim($search_tvaintra))) {
|
||||
$sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')";
|
||||
}
|
||||
$sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
@ -256,6 +268,8 @@ if ($result) {
|
||||
print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
|
||||
print '<td class="liste_titre" align="center"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="' . dol_escape_htmltag($search_account) . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '"></td>';
|
||||
print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tavintra" value="' . dol_escape_htmltag($search_tavintra) . '"></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
$searchpicto=$form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
@ -273,6 +287,8 @@ if ($result) {
|
||||
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'align="center"', $sortfield, $sortorder);
|
||||
$checkpicto=$form->showCheckAddButtons();
|
||||
print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"');
|
||||
print "</tr>\n";
|
||||
@ -325,7 +341,8 @@ if ($result) {
|
||||
print $codecompta . ' <a href="./card.php?id=' . $objp->rowid . '">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
|
||||
print '<td align="right">' . $objp->country .'</td>';
|
||||
print '<td align="center">' . $objp->tva_intra . '</td>';
|
||||
print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->rowid . '"/></td>';
|
||||
|
||||
print "</tr>";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user