Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2016-02-15 00:46:20 +01:00
commit 4d4a35c93f
6 changed files with 628 additions and 3 deletions

View File

@ -0,0 +1,281 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2015 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/bookkeeping/balance.php
* \ingroup Accounting Expert
* \brief Balance of book keeping
*/
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
// Langs
$langs->load("accountancy");
$page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$action = GETPOST('action', 'alpha');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
if ($search_accountancy_code_start == - 1) {
$search_accountancy_code_start = '';
}
$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
if ($search_accountancy_code_end == - 1) {
$search_accountancy_code_end = '';
}
if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) {
$action = 'export_csv';
}
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
$object = new BookKeeping($db);
$formventilation = new FormVentilation($db);
$formother = new FormOther($db);
$form = new Form($db);
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$search_accountancy_code_start = '';
$search_accountancy_code_end = '';
$search_date_start = '';
$search_date_end = '';
}
if (empty($search_date_start)) {
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
}
if ($sortorder == "")
$sortorder = "ASC";
if ($sortfield == "")
$sortfield = "t.rowid";
$options = '';
$filter = array ();
if (! empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$options .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
}
if (! empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$options .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
}
if (! empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start;
$options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
}
if (! empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end;
$options .= '&amp;search_accountancy_code_end=' . $search_accountancy_code_end;
}
/*
* Action
*/
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = 'bookkepping';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
foreach ( $object->lines as $line ) {
if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
// Model Cegid Expert Export
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $date . $sep;
print $line->code_journal . $sep;
print length_accountg($line->numero_compte) . $sep;
print ' ' . $sep;
print $line->sens . $sep;
print price($line->montant) . $sep;
print dol_trunc($line->label_compte, 32) . $sep;
print $line->doc_ref . $sep;
/*print $line->piece_num . $sep;
print length_accounta($line->code_tiers) . $sep;
print . $sep;
print price($line->debit) . $sep;
print price($line->credit) . $sep;*/
print "\n";
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Std export
$date = dol_print_date($line->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
print $date . $sep;
print $line->doc_ref . $sep;
print length_accounta($line->numero_compte) . $sep;
print length_accountg($line->code_tiers) . $sep;
print price($line->debit) . $sep;
print price($line->credit) . $sep;
/*print $line->piece_num . $sep;
print $line->label_compte . $sep;
print price($line->montant) . $sep;
print $line->sens . $sep;*/
print $line->code_journal . $sep;
print "\n";
} elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 3) {
// Coala export
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date . $sep;
print $line->code_journal . $sep;
print length_accounta($line->numero_compte) . $sep;
print $line->piece_num . $sep;
print $line->doc_ref . $sep;
print price($line->debit) . $sep;
print price($line->credit) . $sep;
print 'E' . $sep;
print length_accountg($line->code_tiers) . $sep;
print "\n";
}
}
}
else {
$title_page = $langs->trans("AccountBalance") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
llxHeader('', $title_page);
/*
* List
*/
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords);
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
print '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>';
print '</div>';
print '<div class="liste_titre">';
print $langs->trans('DateStart') . ': ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
print $langs->trans('DateEnd') . ': ';
print $form->select_date($search_date_end, 'date_end', 0, 0, 1);
print '</div>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Numerocompte"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td>';
print $langs->trans('From');
print $formventilation->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '');
print '<br>';
print $langs->trans('To');
print $formventilation->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array (), 1, 1, '');
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</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 '&nbsp;';
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;
$total_debit = 0;
$total_credit = 0;
foreach ( $object->lines as $line ) {
$var = ! $var;
$total_debit += $line->debit;
$total_credit += $line->credit;
print "<tr $bc[$var]>";
print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($line->credit - $line->debit) . '</td>';
print '<td align="center">';
print '</td>';
print "</tr>\n";
}
print '<tr class="liste_total">';
print '<td></td>';
print '<td align="right">';
print price($total_debit);
print '</td>';
print '<td align="right">';
print price($total_credit);
print '</td>';
print '<td align="right">' . price($total_credit - $total_debit) . '</td>';
print '<td align="right"></td>';
print '</tr>';
print "</table>";
print '</form>';
llxFooter();
}
$db->close();

View File

@ -208,8 +208,8 @@ print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, "", $sortfield, $sortorder);
print '<td class="liste_titre" align="right">';
print '</td>';
print '<th class="liste_titre" align="right"><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")) . '"></td>';
print "</tr>\n";
print '<tr class="liste_titre">';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015-*2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -642,6 +642,86 @@ class BookKeeping extends CommonObject
}
}
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = 'SELECT';
$sql .= " t.numero_compte,";
$sql .= " SUM(t.debit) as debit,";
$sql .= " SUM(t.credit) as credit";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter
$sqlwhere = array ();
if (count($filter) > 0) {
foreach ( $filter as $key => $value ) {
if ($key == 't.doc_date') {
$sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
$sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.code_tiers' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
}
}
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere);
}
$sql .= ' GROUP BY t.numero_compte';
if (! empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array ();
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
$line = new BookKeepingLine();
$line->numero_compte = $obj->numero_compte;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$this->lines[] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/**
* Update object into database
*

View File

@ -986,6 +986,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
// General Ledger
if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=accountancy_bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping');
if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php?leftmenu=accountancy_bookkeeping",$langs->trans("AccountBalance"),2,$user->rights->accounting->mouvements->lire);
if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php?leftmenu=accountancy_bookkeeping",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire);
if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php?leftmenu=accountancy_bookkeeping",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire);

View File

@ -0,0 +1,254 @@
<?php
/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/margin/checkMargins.php
* \ingroup margin
* \brief Check margins
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.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 . '/margin/lib/margins.lib.php';
$langs->load("companies");
$langs->load("bills");
$langs->load("products");
$langs->load("margins");
// Security check
if ($user->rights->margins->creer) {
$agentid = $user->id;
} else {
accessforbidden();
}
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
if (! $sortorder)
$sortorder = "DESC";
if (! $sortfield) {
$sortfield = 'f.rowid';
}
$page = GETPOST("page", 'int');
if ($page == - 1) {
$page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
// Both test are required to be compatible with all browsers
if (GETPOST("button_search_x") || GETPOST("button_search")) {
$action = 'search';
} elseif (GETPOST("button_updatemagins_x") || GETPOST("button_updatemagins")) {
$action = 'update';
}
if ($action == 'update') {
$datapost = $_POST;
foreach ( $datapost as $key => $value ) {
if (strpos($key, 'buyingprice_') !== false) {
$tmp_array = explode('_', $key);
if (count($tmp_array) > 0) {
$invoicedet_id = $tmp_array[1];
if (! empty($invoicedet_id)) {
$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facturedet';
$sql .= ' SET buy_price_ht=\'' . price2num($value) . '\'';
$sql .= ' WHERE rowid=' . $invoicedet_id;
$result = $db->query($sql);
if (!$result) {
setEventMessages($db->lasterror, null, 'errors');
}
}
}
}
}
}
$startdate = $enddate = '';
$startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int'));
$enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear', 'int'));
if (! empty($startdate)) {
$options .= '&amp;startdatemonth=' . GETPOST('startdatemonth', 'int') . '&amp;startdateday=' . GETPOST('startdateday', 'int') . '&amp;startdateyear=' . GETPOST('startdateyear', 'int');
}
if (! empty($enddate)) {
$options .= '&amp;enddatemonth=' . GETPOST('enddatemonth', 'int') . '&amp;enddateday=' . GETPOST('enddateday', 'int') . '&amp;enddateyear=' . GETPOST('enddateyear', 'int');
}
/*
* View
*/
$userstatic = new User($db);
$companystatic = new Societe($db);
$invoicestatic = new Facture($db);
$productstatic = new Product($db);
$form = new Form($db);
$title = $langs->trans("CheckMargins");
llxHeader('', $title);
// print_fiche_titre($text);
// Show tabs
$head = marges_prepare_head($user);
$picto = 'margin';
dol_fiche_head($head, 'checkMargins', $title, 0, $picto);
print '<form method="post" name="sel" action="' . $_SERVER['PHP_SELF'] . '">';
print '<table class="border" width="100%">';
// Start date
print '<td>' . $langs->trans('StartDate') . ' (' . $langs->trans("DateValidation") . ')</td>';
print '<td width="20%">';
$form->select_date($startdate, 'startdate', '', '', 1, "sel", 1, 1);
print '</td>';
print '<td width="20%">' . $langs->trans('EndDate') . ' (' . $langs->trans("DateValidation") . ')</td>';
print '<td width="20%">';
$form->select_date($enddate, 'enddate', '', '', 1, "sel", 1, 1);
print '</td>';
print '<td style="text-align: center;">';
print '<input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Launch')) . '" name="button_search" />';
print '</td></tr>';
print "</table>";
$sql = "SELECT";
$sql .= " f.facnumber, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty";
$sql .= " ,d.fk_product";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f ";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as d ON d.fk_facture = f.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid";
$sql .= " WHERE f.fk_statut > 0";
$sql .= " AND f.entity = " . getEntity('facture', 1);
if (! empty($startdate))
$sql .= " AND f.datef >= '" . $db->idate($startdate) . "'";
if (! empty($enddate))
$sql .= " AND f.datef <= '" . $db->idate($enddate) . "'";
$sql .= " AND d.buy_price_ht IS NOT NULL";
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
dol_syslog(__FILE__, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$nbtotalofrecords = $db->num_rows($result);
} else {
setEventMessages($db->lasterror, null, 'errors');
}
}
$sql .= $db->plimit($conf->liste_limit + 1, $offset);
dol_syslog(__FILE__, LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "f.ref", "", $options, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "", "", $options, 'width=20%', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("UnitPriceHT"), $_SERVER["PHP_SELF"], "d.subprice", "", $options, 'align="right"', $sortfield, $sortorder);
if ($conf->global->MARGIN_TYPE == "1") {
print_liste_field_titre($langs->trans("BuyingPrice"), $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder);
} else {
print_liste_field_titre($langs->trans("CostPrice"), $_SERVER["PHP_SELF"], "d.buy_price_ht", "", $options, 'align="right"', $sortfield, $sortorder);
}
print_liste_field_titre($langs->trans("Qty"), $_SERVER["PHP_SELF"], "d.qty", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AmountTTC"), $_SERVER["PHP_SELF"], "d.total_ht", "", $options, 'align="right"', $sortfield, $sortorder);
print "</tr>\n";
if ($num > 0) {
$var = true;
while ( $objp = $db->fetch_object($result) ) {
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td>';
$result_inner = $invoicestatic->fetch($objp->invoiceid);
if ($result_inner < 0) {
setEventMessages($invoicestatic->error, null, 'errors');
} else {
print $invoicestatic->getNomUrl(1);
}
print '</td>';
print '<td>';
if (! empty($objp->fk_product)) {
$result_inner = $productstatic->fetch($objp->fk_product);
if ($result_inner < 0) {
setEventMessages($productstatic->error, null, 'errors');
} else {
print $productstatic->getNomUrl(1);
}
} else {
print $objp->label;
print '&nbsp;';
print $objp->description;
}
print '</td>';
print '<td align="right">';
print price($objp->subprice);
print '</td>';
print '<td align="right">';
print '<input type="text" name="buyingprice_' . $objp->invoicedetid . '" id="buyingprice_' . $objp->invoicedetid . '" size="6" value="' . price($objp->buy_price_ht) . '" class="flat">';
print '</td>';
print '<td align="right">';
print $objp->qty;
print '</td>';
print '<td align="right">';
print price($objp->total_ht);
print '</td>';
print "</tr>\n";
$i ++;
}
}
print "</table>";
} else {
dol_print_error($db);
}
print '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><input type="submit" name="button_updatemagins" id="button_updatemagins" class="butAction" value="' . $langs->trans("Update") . '" /></div>';
print '</div>';
print '</form>';
$db->free($result);
llxFooter();
$db->close();

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -87,6 +88,14 @@ function marges_prepare_head()
$head[$h][1] = $langs->trans($title);
$head[$h][2] = 'agentMargins';
if ($user->rights->margins->creer) {
$h++;
$head[$h][0] = DOL_URL_ROOT."/margin/checkMargins.php";
$head[$h][1] = $langs->trans('CheckMargins');
$head[$h][2] = 'checkMargins';
}
return $head;
}