Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into develop

This commit is contained in:
Darkjeff 2017-07-08 09:31:35 +02:00
commit f44f8b90e9
74 changed files with 2018 additions and 625 deletions

View File

@ -1,4 +1,4 @@
JOURNALCODE JOURNALLIB ECRITURENUM ECRITUREDATE COMPTENUM COMPTELIB COMPAUXNUM COMPAUXLIB PIECEREF PIECEDATE ECRITURELIB DEBIT CREDIT ECRITURELET DATELET VALIDDATE MONTANTDEVISE IDEVISE
JOURNALCODE JOURNALLIB ECRITURENUM ECRITUREDATE COMPTENUM COMPTELIB COMPAUXNUM COMPAUXLIB PIECEREF PIECEDATE ECRITURELIB DEBIT CREDIT ECRITURELET DATELET VALIDDATE MONTANTDEVISE IDEVISE
Banque Banque 17293 20170109 401PPRO PUBLI-PROV L08 20170109 PPRO domiciliation 1TR 187,20 0,00 20170109
Banque Banque 17293 20170109 5121CRA CR AGRICOLE L08 20170109 PPRO domiciliation 1TR 0,00 187,20 20170109
Banque Banque 17295 20170109 401ORPA ORANGE PARIS Report 20170109 ORPA adsl par 12 96,00 0,00 20170109

View File

@ -1,23 +0,0 @@
#!/bin/bash
# vim:ft=sh:ts=3:sts=3:sw=3:et:
###
# Strips the closing php tag `?>` and any following blank lines from the
# end of any PHP file in the current working directory and sub-directories. Files
# with non-whitespace characters following the closing tag will not be affected.
#
# Author: Bryan C. Geraghty <bryan@ravensight.org>
# Date: 2009-10-28
# Source: http://bryan.ravensight.org/2010/07/remove-php-closing-tag/
##
FILES=$(pcregrep -rnM --include='^.*\.php$' '^\?\>(?=([\s\n]+)?$(?!\n))' .);
for MATCH in $FILES;
do
FILE=`echo $MATCH | awk -F ':' '{print $1}'`;
TARGET=`echo $MATCH | awk -F ':' '{print $2}'`;
LINE_COUNT=`wc -l $FILE | awk -F " " '{print $1}'`;
echo "Removing lines ${TARGET} through ${LINE_COUNT} from file $FILE...";
sed -i "${TARGET},${LINE_COUNT}d" $FILE;
done;

View File

@ -46,7 +46,7 @@ if ($cat_id == 0) {
}
// Security check
if (! empty($user->rights->accountancy->chartofaccount))
if (empty($user->rights->accounting->chartofaccount))
{
accessforbidden();
}
@ -104,7 +104,7 @@ $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0
print '<input class="button" type="submit" value="' . $langs->trans("Select") . '">';
print '</td></tr>';
if (! empty($cat_id))
if (! empty($cat_id))
{
$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
if ($return < 0) {
@ -164,4 +164,4 @@ if ($action == 'display' || $action == 'delete') {
llxFooter();
$db->close();
$db->close();

View File

@ -57,7 +57,7 @@ $rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha');
// Security access
if (! empty($user->rights->accountancy->chartofaccount))
if (empty($user->rights->accounting->chartofaccount))
{
accessforbidden();
}

View File

@ -42,7 +42,7 @@ $langs->load("salaries");
$langs->load("loan");
// Security check
if (! empty($user->rights->accountancy->chartofaccount))
if (empty($user->rights->accounting->chartofaccount))
{
accessforbidden();
}

View File

@ -38,7 +38,7 @@ $langs->load("admin");
$langs->load("accountancy");
// Security check
if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount))
if (empty($user->admin) && empty($user->rights->accounting->chartofaccount))
{
accessforbidden();
}

View File

@ -43,10 +43,10 @@ $id = GETPOST('id', 'int');
// List of statut
static $tmpstatut2label = array (
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
'1' => 'CloseFiscalYear'
);
$statut2label = array (
''
''
);
foreach ( $tmpstatut2label as $key => $val )
$statut2label[$key] = $langs->trans($val);
@ -69,7 +69,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
else if ($action == 'add') {
if (! GETPOST('cancel', 'alpha')) {
@ -113,7 +113,7 @@ else if ($action == 'add') {
header("Location: ./fiscalyear.php");
exit();
}
}
}
// Update record
else if ($action == 'update') {
@ -126,7 +126,7 @@ else if ($action == 'update') {
$object->statut = GETPOST('statut', 'int');
$result = $object->update($user);
if ($result > 0) {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
@ -151,7 +151,7 @@ llxHeader("",$title,$helpurl);
$form = new Form($db);
if ($action == 'create')
if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewFiscalYear"));
@ -184,7 +184,7 @@ if ($action == 'create')
print $form->selectarray('statut', $statut2label, GETPOST('statut'));
print '</td></tr>';
*/
print '</table>';
dol_fiche_end();
@ -306,9 +306,9 @@ if ($action == 'create')
print '<div class="tabsAction">';
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
// print '<a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
print '</div>';
}
}

View File

@ -266,7 +266,7 @@ if (! empty($user->admin))
}
// Param a user $user->rights->accountancy->chartofaccount can access
// Param a user $user->rights->accounting->chartofaccount can access
foreach ($list as $key)
{
print '<tr class="oddeven value">';

View File

@ -41,7 +41,7 @@ $rowid=GETPOST('rowid','alpha');
$code=GETPOST('code','alpha');
// Security access
if (! empty($user->rights->accountancy->chartofaccount))
if (empty($user->rights->accounting->chartofaccount))
{
accessforbidden();
}
@ -134,6 +134,7 @@ $elementList = array();
'2' => $langs->trans('AccountingJournalType2'),
'3' => $langs->trans('AccountingJournalType3'),
'4' => $langs->trans('AccountingJournalType4'),
'5' => $langs->trans('AccountingJournalType5'),
'9' => $langs->trans('AccountingJournalType9')
);
@ -743,4 +744,4 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
print '</td>';
}
}
}
}

View File

@ -0,0 +1,331 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@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 accounting/bookkeeping/thirdparty_lettrage.php
* \ingroup Accounting Expert
* \brief Onglet de gestion de parametrages des ventilations
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "bk.rowid";
$search_year = GETPOST ( "search_year" );
// Security check
$socid = GETPOST("socid",'int');
// if ($user->societe_id) $socid=$user->societe_id;
$object = new Societe($db);
$object->id = $socid;
$object->fetch($socid);
$form = new Form($db);
$BookKeeping = new lettering($db);
$formaccounting = new FormAccounting($db);
/*
* Action
*/
if ($action == 'lettering') {
$result = $BookKeeping->updatelettrage($_POST['ids']);
// var_dump($result);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
if ($action == 'autolettrage') {
$result = $BookKeeping->LettrageTiers($socid);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
llxHeader ( '', 'Compta - Grand Livre' );
/*
* Affichage onglets
*/
$head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
print '<table width="100%" class="border">';
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">';
$object->next_prev_filter="te.fournisseur = 1";
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
}
print '<tr>';
print '<td class="nowrap">'.$langs->trans("CustomerCode"). '</td><td colspan="3">';
print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td>';
print '</tr>';
$langs->load('compta');
print '<tr>';
print '<td>';
print $form->editfieldkey("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("CustomerAccountancyCode",'customeraccountancycode',$object->code_compta,$object,$user->rights->societe->creer);
print '</td>';
print '</tr>';
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($object->address,'gmap','thirdparty',$object->id);
print '</td></tr>';
// Zip / Town
print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>';
print '</tr>';
// Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
//$img=picto_from_langcode($object->country_code);
$img='';
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->country;
print '</td></tr>';
print '</table>';
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE (bk.code_tiers = '" . $object->code_compta . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_CUSTOMER. "' )" ;
if (dol_strlen ( $search_year )) {
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )";
}
$sql .= " ORDER BY bk.lettering_code ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset );
// echo $sql;
// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
print '<form name="add" action="?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="action" value="lettering">';
print '<input type="hidden" name="socid" value="'.$object->id.'">';
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td></td>';
print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" );
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" );
// print_liste_field_titre ( $langs->trans ( "Numerocompte" ), "liste.php", "bk.numero_compte" );
// print_liste_field_titre ( $langs->trans ( "Code_tiers" ), "liste.php", "bk.code_tiers" );
print_liste_field_titre ( $langs->trans ( "Labelcompte" ), "liste.php", "bk_label_compte" );
print_liste_field_titre ( $langs->trans ( "Debit" ), "liste.php", "bk.debit" );
print_liste_field_titre ( $langs->trans ( "Credit" ), "liste.php", "bk.credit" );
// print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" );
// print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" );
print '<td></td>';
print '<td></td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="" method="GET">';
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
print '<td><input type="text" name="search_doc_type" value="' . $_GET ["search_doc_type"] . '"></td>';
print '<td><input type="text" name="search_year" value="' . $_GET ["search_year"] . '"></td>';
print '<td><input type="text" name="search_doc_refe" value="' . $_GET ["search_doc_ref"] . '"></td>';
// print '<td><input type="text" name="search_compte" value="' . $_GET ["search_compte"] . '"></td>';
// print '<td><input type="text" name="search_tiers" value="' . $_GET ["search_tiers"] . '"></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
// print '<td>&nbsp;</td>';
// print '<td>&nbsp;</td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</form>';
print '</tr>';
$var = false;
$debit = 0;
$credit = 0;
$solde = 0;
$tmp = '';
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
if($tmp !=$obj->lettering_code || empty($tmp) )
$tmp =$obj->lettering_code;
if($tmp !=$obj->lettering_code || empty($obj->lettering_code))
$var = ! $var;
$debit+= $obj->debit;
$credit+= $obj->credit;
$solde+=($obj->credit-$obj->debit);
print "<tr $bc[$var]>";
print '<td>' . $obj->rowid . '</td>';
if(empty($obj->lettering_code)){
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">';
print img_edit ();
print '</a>&nbsp;' . $obj->doc_type . '</td>' . "\n";
}
else
print '<td>'.$obj->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
// print '<td>' . $obj->numero_compte . '</td>';
// print '<td>' . $obj->code_tiers . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td>' . $obj->debit . '</td>';
print '<td>' . $obj->credit . '</td>';
// print '<td>' . $obj->montant . '</td>';
// print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>';
print '<td>' . round($solde, 2) . '</td>';
if(empty($obj->lettering_code)){
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
}
else
print '<td>' . $obj->lettering_code . '</td>';
print "</tr>\n";
$i ++;
}
print '<tr class="oddeven">';
print '<td colspan="4">Mouvement totaux</td>' . "\n";
print '<td></td>';
// print '<td></td>';
// print '<td></td>';
print '<td><strong>' . $debit . '</strong></td>';
print '<td><strong>' . $credit . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "<tr $bc[$var]>";
print '<td colspan="5">Solde Comptable</td>' . "\n";
// print '<td></td>';
// print '<td></td>';
print '<td></td>';
print '<td><strong>' . ($credit-$debit) . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "</table>";
print '<input class="butAction" type="submit" value="lettering">';
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
print "</form>";
$db->free($resql);
} else {
dol_print_error($db);
}
// End of page
llxFooter();
$db->close();

View File

@ -0,0 +1,335 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@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 accounting/bookkeeping/thirdparty_lettrage.php
* \ingroup Accounting Expert
* \brief Onglet de gestion de parametrages des ventilations
*/
// Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
$action=GETPOST('action','aZ09');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "bk.rowid";
$search_year = GETPOST ( "search_year" );
// Security check
$socid = GETPOST("socid",'int');
// if ($user->societe_id) $socid=$user->societe_id;
$object = new Societe($db);
$object->id = $socid;
$object->fetch($socid);
$form = new Form($db);
$BookKeeping = new lettering($db);
$formaccounting = new FormAccounting($db);
/*
* Action
*/
if ($action == 'lettering') {
$result = $BookKeeping->updatelettrage($_POST['ids']);
// var_dump($result);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
if ($action == 'autolettrage') {
$result = $BookKeeping->LettrageTiers($socid);
if( $result < 0 ){
setEventMessages('', $BookKeeping->errors, 'errors' );
$error++;
}
}
llxHeader ( '', 'Compta - Grand Livre' );
/*
* Affichage onglets
*/
$head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
dol_fiche_head($head, 'TabAccounting', $langs->trans("ThirdParty"),0,'company');
print '<table width="100%" class="border">';
print '<tr><td width="30%">'.$langs->trans("ThirdPartyName").'</td><td width="70%" colspan="3">';
$object->next_prev_filter="te.fournisseur = 1";
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom','','');
print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
}
print '<tr>';
print '<td class="nowrap">'.$langs->trans("SupplierCode"). '</td><td colspan="3">';
print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td>';
print '</tr>';
$langs->load('compta');
print '<tr>';
print '<td>';
print $form->editfieldkey("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
print '</td><td colspan="3">';
print $form->editfieldval("SupplierAccountancyCode",'supplieraccountancycode',$object->code_compta_fournisseur,$object,$user->rights->societe->creer);
print '</td>';
print '</tr>';
// Address
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($object->address,'gmap','thirdparty',$object->id);
print '</td></tr>';
// Zip / Town
print '<tr><td class="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td>';
print '</tr>';
// Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
//$img=picto_from_langcode($object->country_code);
$img='';
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
else print ($img?$img.' ':'').$object->country;
print '</td></tr>';
print '</table>';
// print_r($soc);
// exit;
// [code_compta] => 411DOUA
// [code_compta_fournisseur] => 401SUPPCODE
/*
* Mode Liste
*
*
*
*/
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE (bk.code_tiers = '" . $object->code_compta_fournisseur . "' AND bk.numero_compte = '" .$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER. "' )" ;
if (dol_strlen ( $search_year )) {
$sql .= " AND ( bk.doc_date BETWEEN '" . $search_year . "-0-0' AND '" . ($search_year+1). "-0-0' )";
}
$sql .= " ORDER BY bk.lettering ASC, bk.doc_date ASC" ;//. $db->plimit ( $conf->liste_limit + 1, $offset );
// echo $sql;
// dol_syslog ( "bookkeping:liste:create sql=" . $sql, LOG_DEBUG );
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
print '<form name="add" action="?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="action" value="lettering">';
print '<input type="hidden" name="socid" value="'.$object->id.'">';
print "<table class=\"noborder\" width=\"100%\">";
print '<tr class="liste_titre">';
print '<td></td>';
print_liste_field_titre ( $langs->trans ( "Doctype" ), "liste.php", "bk.doc_type" );
print_liste_field_titre ( $langs->trans ( "Docdate" ), "liste.php", "bk.doc_date" );
print_liste_field_titre ( $langs->trans ( "Docref" ), "liste.php", "bk.doc_ref" );
// print_liste_field_titre ( $langs->trans ( "Numerocompte" ), "liste.php", "bk.numero_compte" );
// print_liste_field_titre ( $langs->trans ( "Code_tiers" ), "liste.php", "bk.code_tiers" );
print_liste_field_titre ( $langs->trans ( "Labelcompte" ), "liste.php", "bk_label_compte" );
print_liste_field_titre ( $langs->trans ( "Debit" ), "liste.php", "bk.debit" );
print_liste_field_titre ( $langs->trans ( "Credit" ), "liste.php", "bk.credit" );
print_liste_field_titre ( $langs->trans ( "Amount" ), "liste.php", "bk.montant" );
print_liste_field_titre ( $langs->trans ( "Sens" ), "liste.php", "bk.sens" );
print_liste_field_titre ( $langs->trans ( "Codejournal" ), "liste.php", "bk.code_journal" );
print '<td></td>';
print '<td></td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="" method="GET">';
print '<input type="hidden" name="socid" value="' . $_GET ["socid"] . '">';
print '<td><input type="text" name="search_doc_type" value="' . $_GET ["search_doc_type"] . '"></td>';
print '<td><input type="text" name="search_year" value="' . $_GET ["search_year"] . '"></td>';
print '<td><input type="text" name="search_doc_refe" value="' . $_GET ["search_doc_ref"] . '"></td>';
// print '<td><input type="text" name="search_compte" value="' . $_GET ["search_compte"] . '"></td>';
// print '<td><input type="text" name="search_tiers" value="' . $_GET ["search_tiers"] . '"></td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</form>';
print '</tr>';
$var = false;
$debit = 0;
$credit = 0;
$solde = 0;
$tmp = '';
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
if($tmp !=$obj->lettering || empty($tmp) )
$tmp =$obj->lettering;
if($tmp !=$obj->lettering || empty($obj->lettering))
$var = ! $var;
$debit+= $obj->debit;
$credit+= $obj->credit;
$solde+=($obj->credit-$obj->debit);
print "<tr $bc[$var]>";
print '<td>' . $obj->rowid . '</td>';
if(empty($obj->lettering)){
print '<td><a href="'.dol_buildpath('/accountancy/bookkeeping/card.php', 1).'?piece_num=' . $obj->piece_num . '">';
print img_edit ();
print '</a>&nbsp;' . $obj->doc_type . '</td>' . "\n";
}
else
print '<td>'.$obj->doc_type . '</td>' . "\n";
print '<td>' . dol_print_date ( $db->jdate ( $obj->doc_date ), 'day' ) . '</td>';
print '<td>' . $obj->doc_ref . '</td>';
// print '<td>' . $obj->numero_compte . '</td>';
// print '<td>' . $obj->code_tiers . '</td>';
print '<td>' . $obj->label_compte . '</td>';
print '<td>' . $obj->debit . '</td>';
print '<td>' . $obj->credit . '</td>';
print '<td>' . $obj->montant . '</td>';
print '<td>' . $obj->sens . '</td>';
print '<td>' . $obj->code_journal . '</td>';
print '<td>' . round($solde, 2) . '</td>';
if(empty($obj->lettering)){
print '<td><input type="checkbox" name="ids[]" value="' . $obj->rowid . '" /></td>';
}
else
print '<td>' . $obj->lettering . '</td>';
print "</tr>\n";
$i ++;
}
print '<tr class="oddeven">';
print '<td colspan="4">Mouvement totaux</td>' . "\n";
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td><strong>' . $debit . '</strong></td>';
print '<td><strong>' . $credit . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "<tr $bc[$var]>";
print '<td colspan="5">Solde Comptable</td>' . "\n";
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td><strong>' . ($credit-$debit) . '</strong></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
print "</table>";
print '<input class="butAction" type="submit" value="lettering">';
print '<a class="butAction" href="?socid='.$object->id.'&action=autolettrage">auto lettering</a>';
print "</form>";
$db->free ( $resql );
} else {
dol_print_error ( $db );
}
// End of page
llxFooter();
$db->close();

View File

@ -539,8 +539,9 @@ class AccountancyCategory
/**
* get cpts of category
*
* @param int $cat_id Category id
* @return array Result in table
* @param int $cat_id Id accounting account category
*
* @return array Result in table
*/
public function getCptsCat($cat_id) {
global $mysoc;

View File

@ -0,0 +1,324 @@
<?php
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@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 2 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 accountancy/class/bookkeeping.class.php
* \ingroup Accounting Expert
* \brief Fichier de la classe des comptes comptable
*/
include_once DOL_DOCUMENT_ROOT."/accountancy/class/bookkeeping.class.php";
include_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
/**
* Class lettering
*/
class lettering extends BookKeeping {
public function LettrageTiers($socid){
$db = $this->db;
$object = new Societe($this->db);
$object->id = $socid;
$object->fetch($socid);
if( $object->code_compta == '411CUSTCODE')
$object->code_compta = '';
if( $object->code_compta_fournisseur == '401SUPPCODE')
$object->code_compta_fournisseur = '';
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.lettering_code, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE code_journal = 'BQ' AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) AND ( bk.date_lettering ='' OR bk.date_lettering IS NULL ) AND bk.lettering_code !='' ";
$sql .= " GROUP BY bk.lettering_code ";
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
$i++;
$sql = "SELECT bk.rowid ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " WHERE bk.lettering_code = '".$obj->lettering_code."' ";
$sql .= " AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) ";
// echo $sql;
$resql2 = $db->query ( $sql );
if ($resql2) {
$num2 = $db->num_rows ( $resql2 );
$i2 = 0;
$ids = array();
while ( $i2 < $num2 ) {
$obj2 = $db->fetch_object ( $resql2 );
$i2++;
$ids[] = $obj2->rowid;
}
if(count($ids) > 1 ){
$result = $this->updatelettrage($ids);
// var_dump($result);
// if( $result < 0 ){
// setEventMessages('', $BookKeeping->errors, 'errors' );
// $error++;
//
// }
}
}
}
}
/**
Prise en charge des lettering complexe avec prelevment , virement
*/
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, bk.code_tiers, bk.numero_compte , bk.label_compte, bk.debit , bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.date_lettering, bu.url_id , bu.type ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu ON(bk.fk_doc = bu.fk_bank AND bu.type IN ('payment', 'payment_supplier') ) ";
$sql .= " WHERE code_journal = 'BQ' AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) AND date_lettering ='' ";
$sql .= " GROUP BY bk.lettering_code ";
// echo $sql;
//
$resql = $db->query ( $sql );
if ($resql) {
$num = $db->num_rows ( $resql );
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object ( $resql );
$ids = array();
$i++;
// print_r($obj);
if($obj->type =='payment_supplier' ) {
$ids[] = $obj->rowid;
$sql= 'SELECT bk.rowid, facf.ref, facf.ref_supplier, payf.fk_bank ';
$sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid";
$sql.= " INNER JOIN " .MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = facf.ref) ";
// $sqlmid.= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid=facf.fk_soc";
// $sqlmid.= " INNER JOIN " . MAIN_DB_PREFIX . "c_paiement as payc ON payc.id=payf.fk_paiement";
$sql .= " WHERE 1 ";
$sql .= " AND fk_paiementfourn = '".$obj->url_id."' ";
// $sql .= " AND (bk.numero_compte = '" . $object->code_compta . "' OR bk.numero_compte = '" . $object->code_compta_fournisseur . "') ";
$sql .= " AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) ";
// echo $sql;
// exit;
}
elseif($obj->type =='payment' ){
$ids[] = $obj->rowid;
$sql= 'SELECT bk.rowid,fac.facnumber , pay.fk_bank ';
$sql.= " FROM " . MAIN_DB_PREFIX . "facture fac ";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid";
$sql.= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid";
$sql.= " INNER JOIN " .MAIN_DB_PREFIX . "accounting_bookkeeping as bk ON( bk.fk_doc = fac.rowid) ";
$sql .= " WHERE 1 ";
$sql .= " AND payfac.fk_paiement = '".$obj->url_id."' ";
$sql .= " AND ( ";
if(!empty($object->code_compta) )
$sql .= " bk.code_tiers = '" . $object->code_compta . "' ";
if(!empty($object->code_compta) && !empty($object->code_compta_fournisseur) )
$sql .= " OR ";
if(!empty($object->code_compta_fournisseur) )
$sql .= " bk.code_tiers = '" . $object->code_compta_fournisseur . "' ";
$sql .= " ) ";
// echo $sql;
}
$resql2 = $db->query ( $sql );
if ($resql2) {
$num2 = $db->num_rows ( $resql2 );
$i2 = 0;
while ( $i2 < $num2 ) {
$obj2 = $db->fetch_object ( $resql2 );
$i2++;
$ids[] = $obj2->rowid;
}
// print_r($ids);
// exit;
if(count($ids) > 1 ){
$result = $this->updatelettrage($ids);
// var_dump($result);
// if( $result < 0 ){
// setEventMessages('', $BookKeeping->errors, 'errors' );
// $error++;
//
// }
}
// exit;
}
}
}
}
public function updatelettrage($ids, $notrigger=false){
$error = 0;
$sql = "SELECT lettering_code FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " lettering_code != '' GROUP BY lettering_code ORDER BY lettering_code DESC limit 1; ";
// echo $sql;
$result = $this->db->query ( $sql );
if ($result) {
$obj = $this->db->fetch_object ( $result );
$lettre = (empty($obj->lettering_code)? 'AAA' : $obj->lettering_code );
if(!empty($obj->lettering_code))
$lettre++;
}
else{
$this->errors[] = 'Error'.$this->db->lasterror();;
$error++;
}
// var_dump(__line__, $error);
$sql = "SELECT SUM(ABS(debit)) as deb, SUM(ABS(credit)) as cred FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE ";
$sql .= " rowid IN (".implode(',', $ids).") ";
$result = $this->db->query ( $sql );
if ($result) {
$obj = $this->db->fetch_object ( $result );
// print_r($obj);
if( !(round(abs($obj->deb),2) === round(abs($obj->cred),2)) ){
// echo $sql;
// print_r($obj);
$this->errors[] = 'Total not exacts '.round(abs($obj->deb),2).' vs '. round(abs($obj->cred),2);
$error++;
}
}
else{
$this->errors[] = 'Erreur sql'.$this->db->lasterror();;
$error++;
}
// Update request
$now = dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET";
$sql.= " lettering_code='".$lettre."'";
$sql.= " , date_lettering = " .$now ; // todo correct date it's false
$sql.= " WHERE rowid IN (".implode(',', $ids).") ";
// echo $sql ;
//
// var_dump(__line__, $error);
// print_r($this->errors);
// exit;
$this->db->begin();
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// var_dump(__line__, $error);
// Commit or rollback
if ($error)
{
// foreach($this->errors as $errmsg)
// {
// dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
// $this->error.=($this->error?', '.$errmsg:$errmsg);
// }
$this->db->rollback();
// echo $this->error;
// var_dump(__line__, $error);
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
}

View File

@ -189,7 +189,8 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accounta
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND product_type <= 2";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='')";
$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_sell ='' OR p.accountancy_code_sell NOT IN
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid ='" . $conf->global->CHARTOFACCOUNTS . "'))";
// Add search filter like
if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1);

View File

@ -75,7 +75,7 @@ $date_endyear = GETPOST('date_endyear');
$in_bookkeeping = GETPOST('in_bookkeeping');
$now = dol_now();
$action = GETPOST('action','alpha');
$action = GETPOST('action','aZ09');
// Security check
if ($user->societe_id > 0 && empty($id_journal))
@ -612,7 +612,7 @@ if (! $error && $action == 'writebookkeeping') {
}
// Export
if ($action == 'export_csv') {
if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@ -760,7 +760,7 @@ if (empty($action) || $action == 'view') {
<script type="text/javascript">
function launch_export() {
console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}

View File

@ -230,7 +230,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
$bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
@ -280,7 +280,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
@ -327,7 +327,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
@ -391,7 +391,7 @@ $companystatic = new Fournisseur($db);
$invoicestatic = new FactureFournisseur($db);
// Export
if ($action == 'export_csv') {
if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
@ -519,7 +519,7 @@ if (empty($action) || $action == 'view') {
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[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}

View File

@ -28,6 +28,7 @@
* \ingroup Advanced accountancy
* \brief Page with sells journal
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
@ -46,7 +47,7 @@ $langs->load("main");
$langs->load("accountancy");
$id_journal = GETPOST('id_journal', 'int');
$action = GETPOST('action','alpha');
$action = GETPOST('action','aZ09');
$date_startmonth = GETPOST('date_startmonth');
$date_startday = GETPOST('date_startday');
@ -246,7 +247,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
$bookkeeping->credit = ($mt < 0) ? $mt : 0;
$bookkeeping->credit = ($mt < 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
@ -292,7 +293,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
@ -338,7 +339,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
$bookkeeping->credit = ($mt >= 0) ? $mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
@ -404,7 +405,7 @@ if ($action == 'writebookkeeping') {
$form = new Form($db);
// Export
if ($action == 'export_csv') {
if ($action == 'exportcsv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
@ -529,7 +530,7 @@ if (empty($action) || $action == 'view') {
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[name=\"action\"]").val("exportcsv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}

View File

@ -191,7 +191,8 @@ $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountan
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version";
$sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql.= " AND product_type <= 2";
$sql.= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy ='')";
$sql.= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy =''OR p.accountancy_code_buy NOT IN
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid ='" . $conf->global->CHARTOFACCOUNTS . "'))";
// Add search filter like
if ($search_lineid) {
$sql .= natural_search("l.rowid", $search_lineid, 1);

View File

@ -187,7 +187,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
print "<input type=\"hidden\" name=\"action\" value=\"update\">";
print "<input type=\"hidden\" name=\"rowid\" value=\"$rowid\">";
print "<input type=\"hidden\" name=\"fk_bank\" value=\"".$object->fk_bank."\">";
dol_fiche_head($head, 'general', $langs->trans("Subscription"), 0, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php">'.$langs->trans("BackToList").'</a>';
@ -199,7 +199,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td>';
print '<td class="valeur" colspan="3">';
print $form->showrefnav($object, 'rowid', $linkback, 1);
print '</td></tr>';
print '</td></tr>';
// Member
$adh->ref=$adh->getFullName($langs);
@ -248,15 +248,15 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit')
}
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
print "\n";
}
@ -274,7 +274,7 @@ if ($rowid && $action != 'edit')
$head = subscription_prepare_head($object);
dol_fiche_head($head, 'general', $langs->trans("Subscription"), '', 'payment');
dol_fiche_head($head, 'general', $langs->trans("Subscription"), -1, 'payment');
// Confirmation to delete subscription
if ($action == 'delete')
@ -292,13 +292,13 @@ if ($rowid && $action != 'edit')
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback, 1);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Member
$adh->ref=$adh->getFullName($langs);
print '<tr>';
@ -349,7 +349,7 @@ if ($rowid && $action != 'edit')
print "</table>\n";
print '</div>';
print '</form>';
dol_fiche_end();
@ -379,11 +379,11 @@ if ($rowid && $action != 'edit')
}
print '</div>';
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
// Documents generes
/*
$filename = dol_sanitizeFileName($object->ref);
@ -391,18 +391,18 @@ if ($rowid && $action != 'edit')
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
$genallowed = $user->rights->facture->creer;
$delallowed = $user->rights->facture->supprimer;
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
$somethingshown = $formfile->numoffiles;
*/
// Show links to link elements
//$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription'));
$somethingshown = $form->showLinkedObjectBlock($object, '');
// Show links to link elements
/*$linktoelem = $form->showLinkToObjectBlock($object,array('order'));
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
// Link for paypal payment
/*
if (! empty($conf->paypal->enabled) && $object->statut != 0) {
@ -411,15 +411,15 @@ if ($rowid && $action != 'edit')
}
*/
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
/*
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'invoice', $socid);
*/
print '</div></div></div>';
print '</div></div></div>';
}

View File

@ -53,7 +53,17 @@ $result = $object->fetch($rowid);
$head = subscription_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Subscription"), '', 'payment');
dol_fiche_head($head, 'info', $langs->trans("Subscription"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/subscription/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback, 1);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
$object->info($rowid);
@ -64,5 +74,7 @@ print '</td></tr></table>';
print '</div>';
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -347,8 +347,9 @@ if ($rowid > 0)
/*
* Hotbar
* Buttons
*/
print '<div class="tabsAction">';
// Edit
@ -482,18 +483,8 @@ if ($rowid > 0)
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Nature"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
print "</tr>\n";
// Lignes des champs de filtre
print '<tr class="liste_titre">';
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>';
@ -516,6 +507,16 @@ if ($rowid > 0)
print "</tr>\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Nature"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
print "</tr>\n";
while ($i < $num && $i < $conf->liste_limit)
{
$objp = $db->fetch_object($resql);
@ -645,9 +646,9 @@ if ($rowid > 0)
print '<table class="border" width="100%">';
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
print $form->selectyesno("subscription",$object->subscription,1);

View File

@ -385,7 +385,7 @@ print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("AGENDA_DEFAULT_VIEW").'</td>'."\n";
print '<td align="center">&nbsp;</td>'."\n";
print '<td align="right">'."\n";
$tmplist=array('show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_list'=>$langs->trans("ViewList"), 'show_peruser'=>$langs->trans("ViewPerUser"));
$tmplist=array('show_list'=>$langs->trans("ViewList"), 'show_month'=>$langs->trans("ViewCal"), 'show_week'=>$langs->trans("ViewWeek"), 'show_day'=>$langs->trans("ViewDay"), 'show_peruser'=>$langs->trans("ViewPerUser"));
print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW);
print '</td></tr>'."\n";

View File

@ -1752,8 +1752,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
}
elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm")
{
$type = (! empty($obj->type)?$obj->type:'user'); // Check if type is different of 'user' (external module)
print '<td>';
print 'user<input type="hidden" name="type" value="user">';
print $type.'<input type="hidden" name="type" value="'.$type.'">';
print '</td>';
}
elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'type_cdr' || $fieldlist[$field] == 'deductible' || $fieldlist[$field] == 'category_type') {

View File

@ -131,9 +131,9 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
{
while (($file = readdir($handle))!==false)
{
if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i",$file,$reg))
if (is_readable($dir.$file) && preg_match("/^mod(.*)\.class\.php$/i",$file,$regmod))
{
$module = strtolower($reg[1]);
$module = strtolower($regmod[1]);
$moduledirforclass = getModuleDirForApiClass($module);
$moduleforperm = $module;
if ($module == 'propale') { $moduleforperm='propal'; }
@ -159,9 +159,9 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
if ($file_searched == 'api_access.class.php') continue;
// Support of the deprecated API.
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$reg))
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$regapi))
{
$classname = ucwords($reg[1]).'Api';
$classname = ucwords($regapi[1]).'Api';
require_once $dir_part.$file_searched;
if (class_exists($classname))
{
@ -173,9 +173,9 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
}
}
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$reg))
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$regapi))
{
$classname = ucwords($reg[1]);
$classname = ucwords($regapi[1]);
$classname = str_replace('_', '', $classname);
require_once $dir_part.$file_searched;
if (class_exists($classname))
@ -206,7 +206,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
}
// Call one APIs or one definition of an API
if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' && preg_match('/^\/resources.json\/(.+)$/', $reg[2], $regbis))))
if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' && preg_match('/^\/resources.json\/(.+)$/', $reg[2], $regbis) && $regbis[1] != 'root')))
{
$module = $reg[1];
if ($module == 'explorer') // If we call page to explore details of a service

View File

@ -49,6 +49,7 @@ class Categorie extends CommonObject
const TYPE_MEMBER = 3; // TODO Replace this value with 'member'
const TYPE_CONTACT = 4; // TODO Replace this value with 'contact'
const TYPE_USER = 4; // categorie contact and user are same ! TODO Replace this value with 'user'
const TYPE_ACCOUNT = 5; // TODO Replace this value with 'bank_account'
const TYPE_PROJECT = 6;
const TYPE_BANK_LINE = 'bank_line';
@ -1174,11 +1175,11 @@ class Categorie extends CommonObject
*/
if($obj[0] > 0 && $obj[0] != $this->id)
{
dol_syslog(get_class($this)."::already_exists category with name=".$this->label." exist rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
dol_syslog(get_class($this)."::already_exists category with name=".$this->label." and parent ".$this->fk_parent." exists: rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
return 1;
}
}
dol_syslog(get_class($this)."::already_exists no category with same name=".$this->label." rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
dol_syslog(get_class($this)."::already_exists no category with same name=".$this->label." and same parent ".$this->fk_parent.": rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
return 0;
}
else

View File

@ -955,8 +955,15 @@ if ($id > 0)
// Type of event
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
{
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">';
$formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto");
print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">';
if ($object->type_code != 'AC_OTH_AUTO')
{
$formactions->select_type_actions(GETPOST("actioncode")?GETPOST("actioncode"):$object->type_code, "actioncode","systemauto");
}
else
{
print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">'.$langs->trans("Action".$object->type_code);
}
print '</td></tr>';
}

View File

@ -59,9 +59,9 @@ else
if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
$search_title=GETPOST('search_title','alpha');
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear'));
$datestart=dol_mktime(0, 0, 0, GETPOST('datestartmonth'), GETPOST('datestartday'), GETPOST('datestartyear'));
$dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth'), GETPOST('dateendday'), GETPOST('dateendyear'));
$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int'));
$datestart=dol_mktime(0, 0, 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int'));
$dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int'));
if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS);
if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW);
@ -168,7 +168,7 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($actioncode != '') $param.="&actioncode=".$actioncode;
if ($resourceid > 0) $param.="&resourceid=".$resourceid;
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status;
if ($status != '' && $status > -1) $param.="&status=".$status;
if ($filter) $param.="&filter=".$filter;
if ($filtert) $param.="&filtert=".$filtert;
if ($socid) $param.="&socid=".$socid;
@ -177,6 +177,13 @@ if ($pid) $param.="&projectid=".$pid;
if ($type) $param.="&type=".$type;
if ($usergroup) $param.="&usergroup=".$usergroup;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($search_title != '') $param.='&search_title='.$search_title;
if (GETPOST('datestartday','int')) $param.='&datestartday='.GETPOST('datestartday','int');
if (GETPOST('datestartmonth','int')) $param.='&datestartmonth='.GETPOST('datestartmonth','int');
if (GETPOST('datestartyear','int')) $param.='&datestartyear='.GETPOST('datestartyear','int');
if (GETPOST('dateendday','int')) $param.='&dateendday='.GETPOST('dateendday','int');
if (GETPOST('dateendmonth','int')) $param.='&dateendmonth='.GETPOST('dateendmonth','int');
if (GETPOST('dateendyear','int')) $param.='&dateendyear='.GETPOST('dateendyear','int');
$sql = "SELECT";
if ($usergroup > 0) $sql.=" DISTINCT";
@ -340,11 +347,13 @@ if ($resql)
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
{
$newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
$tmpforcreatebutton=dol_getdate(dol_now(), true);
$newparam.='&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
//$param='month='.$monthshown.'&year='.$year;
$hourminsec='100000';
$link = '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$year,$month,$day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">';
$link = '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$tmpforcreatebutton['year'],$tmpforcreatebutton['mon'],$tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">';
$link.= $langs->trans("NewAction");
$link.= '</a>';
}
@ -520,7 +529,7 @@ if ($resql)
// Status/Percent
$datep=$db->jdate($obj->datep);
print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent,3,1,$datep).'</td>';
print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent,3,0,$datep).'</td>';
print '<td></td>';

View File

@ -618,9 +618,10 @@ class Propal extends CommonObject
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency
* @param int $notrigger disable line update trigger
* @return int 0 if OK, <0 if KO
*/
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null, $pu_ht_devise = 0)
function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=0, $pa_ht=0, $label='', $type=0, $date_start='', $date_end='', $array_options=0, $fk_unit=null, $pu_ht_devise = 0, $notrigger=0)
{
global $mysoc;
@ -745,7 +746,7 @@ class Propal extends CommonObject
$this->line->multicurrency_total_tva = $multicurrency_total_tva;
$this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
$result=$this->line->update();
$result=$this->line->update($notrigger);
if ($result > 0)
{
// Reorder if child line
@ -909,23 +910,23 @@ class Propal extends CommonObject
$sql.= $this->socid;
$sql.= ", 0";
$sql.= ", ".$this->remise;
$sql.= ", ".($this->remise_percent?$this->db->escape($this->remise_percent):'null');
$sql.= ", ".($this->remise_absolue?$this->db->escape($this->remise_absolue):'null');
$sql.= ", ".($this->remise_percent?$this->db->escape($this->remise_percent):'NULL');
$sql.= ", ".($this->remise_absolue?$this->db->escape($this->remise_absolue):'NULL');
$sql.= ", 0";
$sql.= ", 0";
$sql.= ", '".$this->db->idate($this->date)."'";
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ", '(PROV)'";
$sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null");
$sql.= ", ".($user->id > 0 ? "'".$user->id."'":"NULL");
$sql.= ", '".$this->db->escape($this->note_private)."'";
$sql.= ", '".$this->db->escape($this->note_public)."'";
$sql.= ", '".$this->db->escape($this->modelpdf)."'";
$sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"null");
$sql.= ", ".$this->cond_reglement_id;
$sql.= ", ".$this->mode_reglement_id;
$sql.= ", ".($this->fin_validite!=''?"'".$this->db->idate($this->fin_validite)."'":"NULL");
$sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : 'NULL');
$sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : 'NULL');
$sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
$sql.= ", '".$this->db->escape($this->ref_client)."'";
$sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"null");
$sql.= ", ".($this->date_livraison!=''?"'".$this->db->idate($this->date_livraison)."'":"NULL");
$sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL');
$sql.= ", ".$this->availability_id;
$sql.= ", ".$this->demand_reason_id;

View File

@ -1411,7 +1411,7 @@ class Commande extends CommonOrder
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la commande meme
$result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
$result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();
@ -2778,9 +2778,10 @@ class Commande extends CommonOrder
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Amount in currency
* @param int $notrigger disable line update trigger
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null, $pu_ht_devise = 0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null, $pu_ht_devise = 0, $notrigger=0)
{
global $conf, $mysoc, $langs, $user;
@ -2935,7 +2936,7 @@ class Commande extends CommonOrder
$this->line->array_options=$array_options;
}
$result=$this->line->update($user);
$result=$this->line->update($user, $notrigger);
if ($result > 0)
{
// Reorder if child line
@ -3243,7 +3244,8 @@ class Commande extends CommonOrder
$response->nbtodo++;
$generic_commande->statut = $obj->fk_statut;
$generic_commande->date_livraison = $obj->delivery_date;
$generic_commande->date_commande = $this->db->jdate($obj->date_commande);
$generic_commande->date_livraison = $this->db->jdate($obj->delivery_date);
if ($generic_commande->hasDelay()) {
$response->nbtodolate++;

View File

@ -37,38 +37,40 @@ if (! $user->rights->banque->transfer)
accessforbidden();
$action = GETPOST('action','alpha');
$error = 0;
/*
* Actions
*/
if ($action == 'add')
if ($action == 'add_confirm')
{
$langs->load("errors");
$dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
$label = GETPOST('label','alpha');
$amount= GETPOST('amount');
$amount_to= GETPOST('amount_to');
if (! $label)
{
$error=1;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), null, 'errors');
}
if (! $amount)
{
$error=1;
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
}
if (! GETPOST('account_from','int'))
{
$error=1;
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferFrom")), null, 'errors');
}
if (! GETPOST('account_to','int'))
{
$error=1;
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferTo")), null, 'errors');
}
if (! $error)
@ -81,17 +83,16 @@ if ($action == 'add')
$accountto=new Account($db);
$accountto->fetch(GETPOST('account_to','int'));
if (($accountto->id != $accountfrom->id) && ($accountto->currency_code == $accountfrom->currency_code))
if ($accountto->id != $accountfrom->id)
{
$db->begin();
$error=0;
$bank_line_id_from=0;
$bank_line_id_to=0;
$result=0;
// By default, electronic transfert from bank to bank
$typefrom='VIR';
$typefrom='PRE';
$typeto='VIR';
if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH)
{
@ -102,7 +103,8 @@ if ($action == 'add')
if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user);
if (! ($bank_line_id_from > 0)) $error++;
if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user);
if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user);
if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user);
if (! ($bank_line_id_to > 0)) $error++;
if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
@ -112,7 +114,7 @@ if ($action == 'add')
if (! $error)
{
$mesgs = $langs->trans("TransferFromToDone","<a href=\"bankentries.php?id=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"bankentries.php?id=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
$mesgs = $langs->trans("TransferFromToDone","<a href=\"card.php?id=".$accountfrom->id."\">".$accountfrom->label."</a>","<a href=\"card.php?id=".$accountto->id."\">".$accountto->label."</a>",$amount,$langs->transnoentities("Currency".$conf->currency));
setEventMessages($mesgs, null, 'mesgs');
$db->commit();
}
@ -124,6 +126,7 @@ if ($action == 'add')
}
else
{
$error++;
setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors');
}
}
@ -143,8 +146,9 @@ $account_from='';
$account_to='';
$label='';
$amount='';
$amount_to='';
if($error)
if ($error)
{
$account_from = GETPOST('account_from','int');
$account_to = GETPOST('account_to','int');
@ -160,11 +164,12 @@ print "<br><br>";
print '<form name="add" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="action" value="add_confirm">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>';
print '<td>'.$langs->trans("TransferFrom").'</td><td>'.$langs->trans("TransferTo").'</td><td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Description").'</td><td>'.$langs->trans("Amount").'</td>';
print '</tr>';
$var=false;
@ -181,7 +186,6 @@ $form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
print "</td>\n";
print '<td><input name="label" class="flat quatrevingtpercent" type="text" value="'.$label.'"></td>';
print '<td><input name="amount" class="flat" type="text" size="6" value="'.$amount.'"></td>';
print "</table>";
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></div>';

View File

@ -16,9 +16,9 @@
*/
/**
* \file htdocs/compta/bank/various_payment/index.php
* \ingroup bank
* \brief List of various payments
* \file htdocs/compta/bank/various_payment/index.php
* \ingroup bank
* \brief List of various payments
*/
require '../../../main.inc.php';
@ -44,7 +44,7 @@ $search_account = GETPOST('search_account','int');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -75,7 +75,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_label="";
$search_amount="";
$search_account='';
$typeid="";
$typeid="";
}
/*
@ -103,11 +103,11 @@ if ($search_label) $sql.=natural_search(array('v.label'), $search_label);
if ($search_amount) $sql.=natural_search("v.amount", $search_amount, 1);
if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account;
if ($filtre) {
$filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre;
$filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre;
}
if ($typeid) {
$sql .= " AND v.fk_typepayment=".$typeid;
$sql .= " AND v.fk_typepayment=".$typeid;
}
$sql.= $db->order($sortfield,$sortorder);
@ -116,48 +116,48 @@ $totalnboflines=0;
$result=$db->query($sql);
if ($result)
{
$totalnboflines = $db->num_rows($result);
$totalnboflines = $db->num_rows($result);
}
$sql.= $db->plimit($limit+1,$offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$var=true;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
if ($typeid) $param.='&amp;typeid='.$typeid;
if ($optioncss != '') $param.='&amp;optioncss='.$optioncss;
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($langs->trans("VariousPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit);
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"v.rowid","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"v.label","",$param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("BankAccount"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("BankAccount"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Sens"),$_SERVER["PHP_SELF"],"v.sens","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
print "</tr>\n";
print '<tr class="liste_titre">';
// Ref
@ -174,85 +174,85 @@ if ($result)
print '</td>';
// Account
if (! empty($conf->banque->enabled))
{
print '<td class="liste_titre">';
$form->select_comptes($search_account,'search_account',0,'',1);
print '</td>';
}
{
print '<td class="liste_titre">';
$form->select_comptes($search_account,'search_account',0,'',1);
print '</td>';
}
// Amount
print '<td class="liste_titre" align="right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'"></td>';
// Sens
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print "</tr>\n";
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
print '<tr class="oddeven">';
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
$variousstatic->id=$obj->rowid;
print '<tr class="oddeven">';
$variousstatic->id=$obj->rowid;
$variousstatic->ref=$obj->rowid;
// Ref
// Ref
print "<td>".$variousstatic->getNomUrl(1)."</td>\n";
// Label payment
print "<td>".dol_trunc($obj->label,40)."</td>\n";
print "<td>".dol_trunc($obj->label,40)."</td>\n";
// Date payment
print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day')."</td>\n";
// Type
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->datep),'day')."</td>\n";
// Type
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
// Account
if (! empty($conf->banque->enabled))
{
print '<td>';
if ($obj->fk_bank > 0)
{
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id=$obj->bid;
$accountstatic->ref=$obj->bref;
$accountstatic->number=$obj->bnumber;
$accountstatic->accountancy_number=$obj->account_number;
$accountstatic->fk_accountancy_journal=$obj->fk_accountancy_journal;
$accountstatic->label=$obj->blabel;
print $accountstatic->getNomUrl(1);
}
else print '&nbsp;';
print '</td>';
}
// Amount
print "<td align=\"right\">".price($obj->amount)."</td>";
// Sens
if (! empty($conf->banque->enabled))
{
print '<td>';
if ($obj->fk_bank > 0)
{
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id=$obj->bid;
$accountstatic->ref=$obj->bref;
$accountstatic->number=$obj->bnumber;
$accountstatic->accountancy_number=$obj->account_number;
$accountstatic->fk_accountancy_journal=$obj->fk_accountancy_journal;
$accountstatic->label=$obj->blabel;
print $accountstatic->getNomUrl(1);
}
else print '&nbsp;';
print '</td>';
}
// Amount
print "<td align=\"right\">".price($obj->amount)."</td>";
// Sens
if ($obj->sens == '1') $sens = $langs->trans("Credit"); else $sens = $langs->trans("Debit");
print "<td align=\"right\">".$sens."</td>";
print "<td></td>";
print "</tr>\n";
print "<td align=\"right\">".$sens."</td>";
print "<td></td>";
print "</tr>\n";
$total = $total + $obj->amount;
$total = $total + $obj->amount;
$i++;
}
$i++;
}
$colspan=4;
if (! empty($conf->banque->enabled)) $colspan++;
print '<tr class="liste_total"><td colspan="'.$colspan.'" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($total)."</td>";
$colspan=4;
if (! empty($conf->banque->enabled)) $colspan++;
print '<tr class="liste_total"><td colspan="'.$colspan.'" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($total)."</td>";
print "<td></td></tr>";
print "</table>";
print '</div>';
print "</table>";
print '</div>';
print '</form>';
$db->free($result);
$db->free($result);
}
else
{
dol_print_error($db);
dol_print_error($db);
}

View File

@ -475,7 +475,13 @@ class FactureRec extends CommonInvoice
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = ".$rowid;
dol_syslog($sql);
if (! $this->db->query($sql))
if ($this->db->query($sql))
{
// Delete linked object
$res = $this->deleteObjectLinked();
if ($res < 0) $error=-3;
}
else
{
$this->error=$this->db->lasterror();
$error=-1;

View File

@ -2652,9 +2652,10 @@ class Facture extends CommonInvoice
* @param int $situation_percent Situation advance percentage
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency
* @param int $notrigger disable line update trigger
* @return int < 0 if KO, > 0 if OK
*/
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0)
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0, $notrigger=0)
{
global $conf,$user;
// Deprecation warning
@ -2812,7 +2813,7 @@ class Facture extends CommonInvoice
$this->line->array_options=$array_options;
}
$result=$this->line->update($user);
$result=$this->line->update($user, $notrigger);
if ($result > 0)
{
// Reorder if child line

View File

@ -173,7 +173,6 @@ class Tva extends CommonObject
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
$sql.= " tms=".$this->db->idate($this->tms).",";
$sql.= " datep=".$this->db->idate($this->datep).",";
$sql.= " datev=".$this->db->idate($this->datev).",";
@ -182,9 +181,7 @@ class Tva extends CommonObject
$sql.= " note='".$this->db->escape($this->note)."',";
$sql.= " fk_bank=".$this->fk_bank.",";
$sql.= " fk_user_creat=".$this->fk_user_creat.",";
$sql.= " fk_user_modif=".$this->fk_user_modif."";
$sql.= " fk_user_modif=".($this->fk_user_modif>0?$this->fk_user_modif:$user->id)."";
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -580,7 +577,7 @@ class Tva extends CommonObject
} else {
$bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), '', '', $user);
}
// Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
if ($bank_line_id > 0)
{
@ -731,7 +728,7 @@ class Tva extends CommonObject
{
return $this->LibStatut($this->statut,$mode);
}
/**
* Renvoi le libelle d'un statut donne
*

View File

@ -83,7 +83,7 @@ function pt ($db, $sql, $date)
while ($i < $num)
{
$obj = $db->fetch_object($result);
print '<tr class="oddeven">';
print '<td class="nowrap">'.$obj->dm."</td>\n";
$total = $total + $obj->mm;
@ -147,14 +147,14 @@ for ($m = 1 ; $m < 13 ; $m++ )
{
$coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m);
$coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m);
$action = "tva";
$object = array(&$coll_listsell, &$coll_listbuy);
$parameters["mode"] = $modetax;
$parameters["year"] = $y;
$parameters["month"] = $m;
$parameters["type"] = 'vat';
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
@ -171,7 +171,7 @@ for ($m = 1 ; $m < 13 ; $m++ )
break;
}
print '<tr class="oddeven">';
print '<td class="nowrap"><a href="quadri_detail.php?leftmenu=tax_vat&month='.$m.'&year='.$y.'">'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'</a></td>';
@ -220,22 +220,67 @@ print '</table>';
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print load_fiche_titre($langs->trans("VATPaid"), '', '');
/*
* Payed
*/
$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm";
$sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'";
$sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'";
$sql.= " AND f.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
$sql.= " AND f.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
$sql.= " GROUP BY dm ORDER BY dm ASC";
pt($db, $sql,$langs->trans("Year")." $y");
print '<br>';
if (! empty($conf->global->MAIN_FEATURES_LEVEL))
{
/*
* Recap
*/
print load_fiche_titre($langs->trans("VATRecap"), '', ''); // need to add translation
$sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm";
$sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f";
$sql1 .= " WHERE f.entity = " . $conf->entity;
$sql1 .= " AND f.datev >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql1 .= " AND f.datev <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
$sql1 .= " GROUP BY dm ORDER BY dm ASC";
$result = $db->query($sql1);
if ($result) {
$obj = $db->fetch_object($result);
print '<table class="noborder" width="100%">';
print "<tr>";
print '<td align="right">' . $langs->trans("VATDue") . '</td>'; // need to add translation
print '<td class="nowrap" align="right">' . price(price2num($total, 1)) . '</td>';
print "</tr>\n";
print "<tr>";
print '<td align="right">' . $langs->trans("VATPaid") . '</td>';
print '<td class="nowrap" align="right">' . price(price2num($obj->mm, 1)) . "</td>\n";
print "</tr>\n";
$restopay = $total - $obj->mm;
print "<tr>";
print '<td align="right">' . $langs->trans("VATRestopay") . '</td>'; // need to add translation
print '<td class="nowrap" align="right">' . price(price2num($restopay, 1)) . '</td>';
print "</tr>\n";
print '</table>';
}
}
print '</div></div>';
llxFooter();

View File

@ -318,34 +318,6 @@ abstract class CommonDocGenerator
return $array_other;
}
/**
* Define array with couple subtitution key => subtitution value
*
* @param Object $object Dolibarr Object
* @param Translate $outputlangs Language object for output
* @param boolean $recursive Want to fetch child array or child object
* @return array Array of substitution key->code
*/
function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) {
$array_other = array();
if(!empty($object)) {
foreach($object as $key => $value) {
if(!empty($value)) {
if(!is_array($value) && !is_object($value)) {
$array_other['object_'.$key] = $value;
}
if(is_array($value) && $recursive){
$array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false);
}
}
}
}
return $array_other;
}
/**
@ -410,10 +382,19 @@ abstract class CommonDocGenerator
$array_key.'_total_ttc'=>price2num($object->total_ttc),
$array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()),
$array_key.'_multicurrency_code' => price2num($object->multicurrency_code),
$array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx),
$array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht),
$array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva),
$array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc),
$array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs),
$array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs),
$array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs),
$array_key.'_note_private'=>$object->note,
$array_key.'_note_public'=>$object->note_public,
$array_key.'_note'=>$object->note_public, // For backward compatibility
// Payments
$array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs),
$array_key.'_already_payed'=>price2num($sumpayed),
@ -421,10 +402,10 @@ abstract class CommonDocGenerator
$array_key.'_already_deposit'=>price2num($sumdeposit),
$array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs),
$array_key.'_already_creditnote'=>price2num($sumcreditnote),
$array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs),
$array_key.'already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'),
$array_key.'_already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'),
// Remain to pay with all know infrmation (except open direct debit requests)
$array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs),
$array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT')
@ -493,6 +474,16 @@ abstract class CommonDocGenerator
'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'),
'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs),
'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'),
'line_multicurrency_code' => price2num($line->multicurrency_code),
'line_multicurrency_subprice' => price2num($line->multicurrency_subprice),
'line_multicurrency_total_ht' => price2num($line->multicurrency_total_ht),
'line_multicurrency_total_tva' => price2num($line->multicurrency_total_tva),
'line_multicurrency_total_ttc' => price2num($line->multicurrency_total_ttc),
'line_multicurrency_subprice_locale' => price($line->multicurrency_subprice, 0, $outputlangs),
'line_multicurrency_total_ht_locale' => price($line->multicurrency_total_ht, 0, $outputlangs),
'line_multicurrency_total_tva_locale' => price($line->multicurrency_total_tva, 0, $outputlangs),
'line_multicurrency_total_ttc_locale' => price($line->multicurrency_total_ttc, 0, $outputlangs),
);
// Retrieve extrafields
@ -601,6 +592,33 @@ abstract class CommonDocGenerator
);
}
/**
* Define array with couple subtitution key => subtitution value
*
* @param Object $object Dolibarr Object
* @param Translate $outputlangs Language object for output
* @param boolean $recursive Want to fetch child array or child object
* @return array Array of substitution key->code
*/
function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) {
$array_other = array();
if(!empty($object)) {
foreach($object as $key => $value) {
if(!empty($value)) {
if(!is_array($value) && !is_object($value)) {
$array_other['object_'.$key] = $value;
}
if(is_array($value) && $recursive){
$array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false);
}
}
}
}
return $array_other;
}
/**
* Fill array with couple extrafield key => extrafield value
*

View File

@ -2463,12 +2463,12 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
* MAIN_DISABLE_TRUNC=1 can disable all truncings
*
* @param string $string String to truncate
* @param int $size Max string size visible. 0 for no limit. Final string size can be 1 more (if size was max+1) or 3 more (if we added ...)
* @param int $size Max string size visible (excluding ...). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added ..., or if size was max+1 or max+2 or max+3 so it does not worse to replace with ...)
* @param string $trunc Where to trunc: right, left, middle (size must be a 2 power), wrap
* @param string $stringencoding Tell what is source string encoding
* @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation.
* @param int $display Trunc is use to display and can be changed for small screen. TODO Remove this param (must be dealt with CSS)
* @return string Truncated string
* @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise.
*/
function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0, $display=0)
{
@ -2484,9 +2484,10 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
if ($trunc == 'right')
{
$newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string;
if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:1)))
if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
return dol_substr($newstring,0,$size,$stringencoding).($nodot?'':'...');
else
//return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
return $string;
}
elseif ($trunc == 'middle')
@ -2504,7 +2505,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
elseif ($trunc == 'left')
{
$newstring=dol_textishtml($string)?dol_string_nohtmltag($string,1):$string;
if (dol_strlen($newstring,$stringencoding) > ($size+1))
if (dol_strlen($newstring,$stringencoding) > ($size+($nodot?0:3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
return '...'.dol_substr($newstring,dol_strlen($newstring,$stringencoding) - $size,$size,$stringencoding);
else
return $string;

0
htdocs/core/lib/functions2.lib.php Executable file → Normal file
View File

View File

@ -357,6 +357,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
$sql = "SELECT rowid, code, label, nature";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " active = 1";
$sql.= " ORDER BY label";
$resql = $db->query($sql);
@ -373,10 +374,10 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
$nature='';
// Must match array $sourceList defined into journals_list.php
if ($objp->nature == 2) $nature="sells";
if ($objp->nature == 3) $nature="purchases";
if ($objp->nature == 4) $nature="bank";
if ($objp->nature == 5) $nature="expensereports";
if ($objp->nature == 2 && ! empty($conf->facture->enabled)) $nature="sells";
if ($objp->nature == 3 && ! empty($conf->fournisseur->enabled)) $nature="purchases";
if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank";
if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) $nature="expensereports";
if ($objp->nature == 1) $nature="various";
if ($objp->nature == 9) $nature="hasnew";

View File

@ -992,6 +992,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$sql = "SELECT rowid, code, label, nature";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " AND active = 1";
$sql.= " ORDER BY label";
$resql = $db->query($sql);

View File

@ -1508,11 +1508,11 @@ class DolibarrModules // Can not be abstract, because we need to insta
// Clean
if (empty($visible)) $visible='0';
if (empty($val)) $val='';
if (empty($val) && $val != '0') $val='';
$sql = "SELECT count(*)";
$sql.= " FROM ".MAIN_DB_PREFIX."const";
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$name."'";
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'";
$sql.= " AND entity = ".$entity;
$result=$this->db->query($sql);
@ -1526,7 +1526,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
$sql.= " VALUES (";
$sql.= $this->db->encrypt($name,1);
$sql.= ",'".$type."'";
$sql.= ",".($val?$this->db->encrypt($val,1):"''");
$sql.= ",".(($val != '')?$this->db->encrypt($val,1):"''");
$sql.= ",".($note?"'".$this->db->escape($note)."'":"null");
$sql.= ",'".$visible."'";
$sql.= ",".$entity;

View File

@ -146,7 +146,7 @@ class pdf_einstein extends ModelePDFCommandes
}
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{

View File

@ -132,7 +132,7 @@ class pdf_crabe extends ModelePDFFactures
$this->posxdiscount=162;
$this->posxprogress=126; // Only displayed for situation invoices
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{

View File

@ -292,10 +292,11 @@ class ImportXlsx extends ModeleImports
* @param Object $objimport Object import (contains objimport->array_import_tables, objimport->array_import_fields, objimport->array_import_convertvalue, ...)
* @param int $maxfields Max number of fields to use
* @param string $importid Import key
* @param array $updatekeys Array of keys to use to try to do update
* @return int <0 if KO, >0 if OK
*/
// What is this doing here ? it is common to all imports, is should be in the parent class
function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid)
function import_insert($arrayrecord,$array_match_file_to_database,$objimport,$maxfields,$importid,$updatekeys)
{
global $langs,$conf,$user;
global $thirdparty_static; // Specific to thirdparty import
@ -326,13 +327,15 @@ class ImportXlsx extends ModeleImports
else
{
$last_insert_id_array = array(); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id (eg: extrafields fk_object will be set with the last inserted object's id)
$updatedone = false;
$insertdone = false;
// For each table to insert, me make a separate insert
foreach($objimport->array_import_tables[0] as $alias => $tablename)
{
// Build sql request
$sql='';
$listfields='';
$listvalues='';
$listfields=array();
$listvalues=array();
$i=0;
$errorforthistable=0;
@ -372,7 +375,7 @@ class ImportXlsx extends ModeleImports
// Make some tests on $newval
// Is it a required field ?
if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval == ''))
if (preg_match('/\*/',$objimport->array_import_fields[0][$val]) && ((string) $newval==''))
{
$this->errors[$error]['lib']=$langs->trans('ErrorMissingMandatoryValue',$key);
$this->errors[$error]['type']='NOTNULL';
@ -399,7 +402,7 @@ class ImportXlsx extends ModeleImports
if ($isidorref == 'ref') // If value into input import file is a ref, we apply the function defined into descriptor
{
$file=$objimport->array_import_convertvalue[0][$val]['classfile'];
$file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']);
$class=$objimport->array_import_convertvalue[0][$val]['class'];
$method=$objimport->array_import_convertvalue[0][$val]['method'];
if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '')
@ -408,7 +411,12 @@ class ImportXlsx extends ModeleImports
}
else
{
dol_include_once($file);
$resultload = dol_include_once($file);
if (empty($resultload))
{
dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method);
break;
}
$classinstance=new $class($this->db);
// Try the fetch from code or ref
call_user_func_array(array($classinstance, $method),array('', $newval));
@ -481,6 +489,26 @@ class ImportXlsx extends ModeleImports
}
if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null"
}
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getrefifauto')
{
$defaultref='';
// TODO provide the $modTask (module of generation of ref) as parameter of import_insert function
$obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON;
if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php"))
{
require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php';
$modTask = new $obj;
$defaultref = $modTask->getNextValue(null,null);
}
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
$newval=$defaultref;
}
elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric')
{
$newval = price2num($newval);
}
//print 'Val to use as insert is '.$newval.'<br>';
}
@ -541,42 +569,37 @@ class ImportXlsx extends ModeleImports
}
// Define $listfields and $listvalues to build SQL request
if ($listfields) { $listfields.=', '; $listvalues.=', '; }
$listfields.=$fieldname;
$listfields[] = $fieldname;
// Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert
if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues.=($newval=='0'?$newval:"null");
elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues.="''";
else $listvalues.="'".$this->db->escape($newval)."'";
if (empty($newval) && $arrayrecord[($key-1)]['type'] < 0) $listvalues[] = ($newval=='0'?$newval:"null");
elseif (empty($newval) && $arrayrecord[($key-1)]['type'] == 0) $listvalues[] = "''";
else $listvalues[] = "'".$this->db->escape($newval)."'";
}
$i++;
}
// We add hidden fields (but only if there is at least one field to add into table)
if ($listfields && is_array($objimport->array_import_fieldshidden[0]))
if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0]))
{
// Loop on each hidden fields to add them into listfields/listvalues
foreach($objimport->array_import_fieldshidden[0] as $key => $val)
{
if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table
if ($listfields) { $listfields.=', '; $listvalues.=', '; }
if ($val == 'user->id')
{
$listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listvalues.=$user->id;
$listfields[] = preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listvalues[] = $user->id;
}
elseif (preg_match('/^lastrowid-/',$val))
{
$tmp=explode('-',$val);
$lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0;
$listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listvalues.=$lastinsertid;
$keyfield = preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listfields[] = $keyfield;
$listvalues[] = $lastinsertid;
//print $key."-".$val."-".$listfields."-".$listvalues."<br>";exit;
} else
{
$listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listvalues.=$val;
}
}
}
}
//print 'listfields='.$listfields.'<br>listvalues='.$listvalues.'<br>';
@ -584,49 +607,114 @@ class ImportXlsx extends ModeleImports
// If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined
if (! $errorforthistable)
{
//print "$alias/$tablename/$listfields/$listvalues<br>";
if ($listfields)
//print "$alias/$tablename/$listfields/$listvalues<br>";
if (!empty($listfields))
{
//var_dump($objimport->array_import_convertvalue); exit;
// Build SQL request
if (empty($tablewithentity_cache[$tablename]))
{
$sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key';
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias];
$sql.=') VALUES('.$listvalues.", '".$importid."'";
}
else
{
$sql ='INSERT INTO '.$tablename.'('.$listfields.', import_key, entity';
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$objimport->array_import_tables_creator[0][$alias];
$sql.=') VALUES('.$listvalues.", '".$importid."', ".$conf->entity ;
}
if (! empty($objimport->array_import_tables_creator[0][$alias])) $sql.=', '.$user->id;
$sql.=')';
//print($sql).'<br>';
dol_syslog("import_csv.modules", LOG_DEBUG);
//print '> '.join(',',$arrayrecord);
//print 'sql='.$sql;
//print '<br>'."\n";
// Run insert request
if ($sql)
{
$resql=$this->db->query($sql);
$last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr).
if ($resql)
{
//print '.';
$updatedone = false;
$insertdone = false;
if (!empty($updatekeys)) {
// We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields)
if (empty($lastinsertid)) {
$sqlSelect = 'SELECT rowid FROM '.$tablename;
$data = array_combine($listfields, $listvalues);
$where = array();
$filters = array();
foreach ($updatekeys as $key) {
$col = $objimport->array_import_updatekeys[0][$key];
$key=preg_replace('/^.*\./i','',$key);
$where[] = $key.' = '.$data[$key];
$filters[] = $col.' = '.$data[$key];
}
$sqlSelect.= ' WHERE '.implode(' AND ', $where);
$resql=$this->db->query($sqlSelect);
if($resql) {
$res = $this->db->fetch_object($resql);
if($resql->num_rows == 1) {
$lastinsertid = $res->rowid;
$last_insert_id_array[$tablename] = $lastinsertid;
} else if($resql->num_rows > 1) {
$this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', '));
$this->errors[$error]['type']='SQL';
$error++;
} else {
// No record found with filters, insert will be tried below
}
}
else
{
//print 'E';
$this->errors[$error]['lib']=$this->db->lasterror();
$this->errors[$error]['type']='SQL';
$error++;
}
}
else
if (!empty($lastinsertid)) {
// Build SQL UPDATE request
$sqlstart = 'UPDATE '.$tablename;
$data = array_combine($listfields, $listvalues);
$set = array();
foreach ($data as $key => $val) {
$set[] = $key.' = '.$val;
}
$sqlstart.= ' SET '.implode(', ', $set);
if(empty($keyfield)) $keyfield = 'rowid';
$sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid;
$sql = $sqlstart.$sqlend;
// Run update request
$resql=$this->db->query($sql);
if($resql) {
// No error, update has been done. $this->db->db->affected_rows can be 0 if data hasn't changed
$updatedone = true;
}
else
{
//print 'E';
$this->errors[$error]['lib']=$this->db->lasterror();
$this->errors[$error]['type']='SQL';
$error++;
}
}
}
// Update not done, we do insert
if (!$error && !$updatedone) {
// Build SQL INSERT request
$sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key';
$sqlend = ') VALUES('.implode(', ', $listvalues).", '".$importid."'";
if (! empty($tablewithentity_cache[$tablename])) {
$sqlstart.= ', entity';
$sqlend.= ', '.$conf->entity;
}
if (! empty($objimport->array_import_tables_creator[0][$alias])) {
$sqlstart.= ', '.$objimport->array_import_tables_creator[0][$alias];
$sqlend.=', '.$user->id;
}
$sql = $sqlstart.$sqlend.')';
dol_syslog("import_xlsx.modules", LOG_DEBUG);
// Run insert request
if ($sql)
{
//print 'E';
$this->errors[$error]['lib']=$this->db->lasterror();
$this->errors[$error]['type']='SQL';
$error++;
$resql=$this->db->query($sql);
if ($resql)
{
$last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr).
$insertdone = true;
}
else
{
//print 'E';
$this->errors[$error]['lib']=$this->db->lasterror();
$this->errors[$error]['type']='SQL';
$error++;
}
}
}
}
@ -638,6 +726,9 @@ class ImportXlsx extends ModeleImports
if ($error) break;
}
if($updatedone) $this->nbupdate++;
if($insertdone) $this->nbinsert++;
}
return 1;

View File

@ -120,7 +120,7 @@ class pdf_azur extends ModelePDFPropales
}
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{

View File

@ -108,7 +108,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$this->posxqty=145;
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{

0
htdocs/core/tpl/objectline_view.tpl.php Executable file → Normal file
View File

View File

@ -65,7 +65,7 @@ class EcmFiles //extends CommonObject
/**
*/
/**
* Constructor
@ -88,13 +88,13 @@ class EcmFiles //extends CommonObject
public function create(User $user, $notrigger = false)
{
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
// Clean parameters
if (isset($this->label)) {
$this->label = trim($this->label);
}
@ -135,13 +135,13 @@ class EcmFiles //extends CommonObject
$this->acl = trim($this->acl);
}
if (empty($this->date_c)) $this->date_c = dol_now();
$maxposition=0;
if (empty($this->position)) // Get max used
{
$sql = "SELECT MAX(position) as maxposition FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql.= " WHERE filepath ='".$this->db->escape($this->filepath)."'";
$resql = $this->db->query($sql);
if ($resql)
{
@ -204,7 +204,7 @@ class EcmFiles //extends CommonObject
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
$this->position = $maxposition;
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
// want this action to call a trigger.
@ -299,7 +299,7 @@ class EcmFiles //extends CommonObject
$this->fk_user_m = $obj->fk_user_m;
$this->acl = $obj->acl;
}
// Retrieve all extrafields for invoice
// fetch optionals attributes and labels
/*
@ -309,7 +309,7 @@ class EcmFiles //extends CommonObject
$this->fetch_optionals($this->id,$extralabels);
*/
// $this->fetch_lines();
$this->db->free($resql);
if ($numrows) {
@ -393,7 +393,7 @@ class EcmFiles //extends CommonObject
$line = new EcmfilesLine();
$line->id = $obj->rowid;
$line->label = $obj->label;
$line->entity = $obj->entity;
$line->filename = $obj->filename;
@ -437,7 +437,7 @@ class EcmFiles //extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
if (isset($this->label)) {
$this->label = trim($this->label);
}
@ -562,7 +562,7 @@ class EcmFiles //extends CommonObject
}
// If you need to delete child tables to, you can insert them here
if (!$error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
$sql .= ' WHERE rowid=' . $this->id;
@ -651,7 +651,7 @@ class EcmFiles //extends CommonObject
global $menumanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = '';
$companylink = '';
@ -660,7 +660,7 @@ class EcmFiles //extends CommonObject
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id;
$linkclose='';
if (empty($notooltip))
{
@ -673,7 +673,7 @@ class EcmFiles //extends CommonObject
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
@ -757,9 +757,9 @@ class EcmFiles //extends CommonObject
public function initAsSpecimen()
{
global $conf,$user;
$this->id = 0;
$this->label = '0a1b2c3e4f59999999';
$this->entity = '1';
$this->filename = 'myspecimenfilefile.pdf';
@ -780,3 +780,23 @@ class EcmFiles //extends CommonObject
}
class EcmfilesLine
{
public $label;
public $entity;
public $filename;
public $filepath;
public $fullpath_orig;
public $description;
public $keywords;
public $cover;
public $position;
public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown'
public $extraparams;
public $date_c = '';
public $date_m = '';
public $fk_user_c;
public $fk_user_m;
public $acl;
}

View File

@ -716,6 +716,7 @@ class Expedition extends CommonObject
if ($result < 0) {
$error++;
$this->errors[]=$mouvS->error;
$this->errors = array_merge($this->errors, $mouvS->errors);
break;
}
}
@ -729,6 +730,7 @@ class Expedition extends CommonObject
if ($result < 0) {
$error++;
$this->errors[]=$mouvS->error;
$this->errors = array_merge($this->errors, $mouvS->errors);
break;
}
}

View File

@ -45,7 +45,7 @@ class CommandeFournisseur extends CommonOrder
public $fk_element = 'fk_commande';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='order';
/**
* {@inheritdoc}
*/
@ -132,9 +132,9 @@ class CommandeFournisseur extends CommonOrder
* Draft status
*/
const STATUS_DRAFT = 0;
/**
* Constructor
*
@ -318,7 +318,7 @@ class CommandeFournisseur extends CommonOrder
$line->subprice = $objp->subprice;
$line->pu_ht = $objp->subprice;
$line->remise_percent = $objp->remise_percent;
$line->vat_src_code = $objp->vat_src_code;
$line->total_ht = $objp->total_ht;
$line->total_tva = $objp->total_tva;
@ -615,7 +615,7 @@ class CommandeFournisseur extends CommonOrder
$picto='order';
$url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id;
$linkclose='';
if (empty($notooltip))
{
@ -627,7 +627,7 @@ class CommandeFournisseur extends CommonOrder
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
}
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
@ -1378,7 +1378,7 @@ class CommandeFournisseur extends CommonOrder
}
$desc=trim($desc);
$ref_supplier=''; // Ref of supplier price when we add line
// Check parameters
if ($qty < 1 && ! $fk_product)
{
@ -1402,7 +1402,7 @@ class CommandeFournisseur extends CommonOrder
{
$product_type = $prod->type;
$label = $prod->label;
// We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok.
// If we want a dedicated supplier price, we must provide $fk_prod_fourn_price.
$result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', $this->fk_soc); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc
@ -1422,7 +1422,7 @@ class CommandeFournisseur extends CommonOrder
$this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier");
$this->db->rollback();
dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price");
//$pu = $prod->fourn_pu; // We do not overwrite unit price
//$pu = $prod->fourn_pu; // We do not overwrite unit price
//$ref = $prod->ref_fourn; // We do not overwrite ref supplier price
return -1;
}
@ -1468,7 +1468,7 @@ class CommandeFournisseur extends CommonOrder
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx,$pu_ht_devise);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
@ -1487,7 +1487,7 @@ class CommandeFournisseur extends CommonOrder
$localtax2_type=$localtaxes_type[2];
$subprice = price2num($pu,'MU');
$rangmax = $this->line_max();
$rang = $rangmax + 1;
@ -1513,7 +1513,7 @@ class CommandeFournisseur extends CommonOrder
$this->line->subprice=$pu_ht;
$this->line->rang=$this->rang;
$this->line->info_bits=$info_bits;
$this->line->vat_src_code=$vat_src_code;
$this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva;
@ -1553,7 +1553,7 @@ class CommandeFournisseur extends CommonOrder
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la commande meme
$result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
$result=$this->update_price(1,'auto',0,$this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();
@ -2001,7 +2001,7 @@ class CommandeFournisseur extends CommonOrder
$old_statut = $this->statut;
$this->statut = $statut;
$this->actionmsg2 = $comment;
// Call trigger
$result=$this->call_trigger('ORDER_SUPPLIER_RECEIVE',$user);
if ($result < 0) $error++;
@ -2334,7 +2334,7 @@ class CommandeFournisseur extends CommonOrder
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
@ -2819,7 +2819,7 @@ class CommandeFournisseur extends CommonOrder
return $text;
}
/**
* Calc status regarding to dispatched stock
*
@ -2828,7 +2828,7 @@ class CommandeFournisseur extends CommonOrder
* @param string $comment Comment
* @return int <0 if KO, 0 if not applicable, >0 if OK
*/
public function calcAndSetStatusDispatch(User $user, $closeopenorder=1, $comment='')
public function calcAndSetStatusDispatch(User $user, $closeopenorder=1, $comment='')
{
global $conf, $langs;
@ -2845,14 +2845,14 @@ class CommandeFournisseur extends CommonOrder
$filter['t.status']=1;
}
$ret=$supplierorderdispatch->fetchAll('','',0,0,$filter);
if ($ret<0)
if ($ret<0)
{
$this->error=$supplierorderdispatch->error; $this->errors=$supplierorderdispatch->errors;
return $ret;
}
else
}
else
{
if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0)
if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0)
{
//Build array with quantity deliverd by product
foreach($supplierorderdispatch->lines as $line) {
@ -2861,12 +2861,12 @@ class CommandeFournisseur extends CommonOrder
foreach($this->lines as $line) {
$qtywished[$line->fk_product]+=$line->qty;
}
$date_liv = dol_now();
//Compare array
$diff_array=array_diff_assoc($qtydelivered,$qtywished);
if (count($diff_array)==0) //No diff => mean everythings is received
{
if ($closeopenorder)
@ -2888,8 +2888,8 @@ class CommandeFournisseur extends CommonOrder
}
return 4;
}
}
else
}
else
{
//Diff => received partially
$ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can'
@ -3014,12 +3014,12 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
$this->fk_unit = $objp->fk_unit;
$this->multicurrency_subprice = $objp->multicurrency_subprice;
$this->multicurrency_total_ht = $objp->multicurrency_total_ht;
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$this->db->free($result);
return 1;
}
@ -3208,7 +3208,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
$sql.= ", subprice='".price2num($this->subprice)."'";
//$sql.= ",remise='".price2num($remise)."'";
$sql.= ", remise_percent='".price2num($this->remise_percent)."'";
$sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->vat_src_code)."'";
$sql.= ", tva_tx='".price2num($this->tva_tx)."'";
$sql.= ", localtax1_tx='".price2num($this->total_localtax1)."'";

View File

@ -1430,7 +1430,7 @@ class FactureFournisseur extends CommonInvoice
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la facture meme
$result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode.
$result=$this->update_price(1,'auto',0,$this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();

View File

@ -699,17 +699,36 @@ class ProductFournisseur extends Product
/**
* Display price of product
*
* @param int $showunitprice Show "Unit price" into output string
* @param int $showsuptitle Show "Supplier" into output string
* @param int $maxlen Max length of name
* @param integer $notooltip 1=Disable tooltip
* @return string String with supplier price
* @param int $showunitprice Show "Unit price" into output string
* @param int $showsuptitl Show "Supplier" into output string
* @param int $maxlen Max length of name
* @param integer $notooltip 1=Disable tooltip
* @param array $productFournList list of ProductFournisseur objects
* to display in table format.
* @return string String with supplier price
*/
function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0)
function display_price_product_fournisseur($showunitprice=1,$showsuptitle=1,$maxlen=0,$notooltip=0, $productFournList=array())
{
global $langs;
$out = '';
$langs->load("suppliers");
$out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").' &nbsp; (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
if (count($productFournList) > 0) {
$out .= '<table class="nobordernopadding" width="100%">';
$out .= '<tr><td class="liste_titre" align="right">'.($showunitprice?$langs->trans("Price").' '.$langs->trans("HT"):'').'</td>';
$out .= '<td class="liste_titre" align="right">'.($showunitprice?$langs->trans("QtyMin"):'').'</td>';
$out .= '<td class="liste_titre">'.$langs->trans("Supplier").'</td>';
$out .= '<td class="liste_titre">'.$langs->trans("SupplierRef").'</td></tr>';
foreach ($productFournList as $productFourn) {
$out.= '<tr><td align="right">'.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').'</td>';
$out.= '<td align="right">'.($showunitprice?$productFourn->fourn_qty:'').'</td>';
$out.= '<td>'.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).'</td>';
$out.= '<td>'.$productFourn->fourn_ref.'<td></tr>';
}
$out .= '</table>';
} else {
$out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").' &nbsp; (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':'');
}
return $out;
}

View File

@ -2704,7 +2704,7 @@ elseif (! empty($object->id))
//print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("ToOrder").'</td></tr>';
print '<tr><td>'.$langs->trans("OrderDate").'</td><td>';
$date_com = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
print $form->select_date($date_com,'',1,1,'',"commande",1,0,1);
print $form->select_date($date_com,'',1,1,'',"commande",1,1,1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("OrderMode").'</td><td>';
@ -2756,7 +2756,7 @@ if ($action != 'makeorder')
print '<table class="noborder" width="100%">';
//print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Receive").'</td></tr>';
print '<tr><td>'.$langs->trans("DeliveryDate").'</td><td>';
print $form->select_date('','',1,1,'',"commande",1,0,1);
print $form->select_date('','',1,1,'',"commande",1,1,1);
print "</td></tr>\n";
print "<tr><td>".$langs->trans("Delivery")."</td><td>\n";

View File

@ -20,7 +20,7 @@
/**
* \file htdocs/holiday/list.php
* \ingroup holiday
* \brief List of holiday.
* \brief List of holiday
*/
require('../main.inc.php');
@ -63,10 +63,10 @@ $month_start = GETPOST('month_start');
$year_start = GETPOST('year_start');
$month_end = GETPOST('month_end');
$year_end = GETPOST('year_end');
$search_employe = GETPOST('search_employe');
$search_employee = GETPOST('search_employee');
$search_valideur = GETPOST('search_valideur');
$search_statut = GETPOST('select_statut');
$type = GETPOST('type','int');
$search_type = GETPOST('search_type','int');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
@ -91,10 +91,10 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$year_start="";
$month_end="";
$year_end="";
$search_employe="";
$search_employee="";
$search_valideur="";
$search_statut="";
$type='';
$search_type='';
}
@ -121,13 +121,13 @@ llxHeader('', $langs->trans('CPTitreMenu'));
$order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset);
// WHERE
// Ref
if(!empty($search_ref))
{
$filter.= " AND cp.rowid LIKE '%".$db->escape($search_ref)."%'\n";
}
// DATE START
// Start date
if($year_start > 0) {
if($month_start > 0) {
$filter .= " AND (cp.date_debut BETWEEN '".$db->idate(dol_get_first_day($year_start,$month_start,1))."' AND '".$db->idate(dol_get_last_day($year_start,$month_start,1))."')";
@ -142,7 +142,7 @@ if($year_start > 0) {
}
}
// DATE FIN
// End date
if($year_end > 0) {
if($month_end > 0) {
$filter .= " AND (cp.date_fin BETWEEN '".$db->idate(dol_get_first_day($year_end,$month_end,1))."' AND '".$db->idate(dol_get_last_day($year_end,$month_end,1))."')";
@ -157,7 +157,7 @@ if($year_end > 0) {
}
}
// DATE CREATE
// Create date
if($year_create > 0) {
if($month_create > 0) {
$filter .= " AND (cp.date_create BETWEEN '".$db->idate(dol_get_first_day($year_create,$month_create,1))."' AND '".$db->idate(dol_get_last_day($year_create,$month_create,1))."')";
@ -172,17 +172,22 @@ if($year_create > 0) {
}
}
// EMPLOYE
if(!empty($search_employe) && $search_employe != -1) {
$filter.= " AND cp.fk_user = '".$db->escape($search_employe)."'\n";
// Employee
if(!empty($search_employee) && $search_employee != -1) {
$filter.= " AND cp.fk_user = '".$db->escape($search_employee)."'\n";
}
// VALIDEUR
// Validator
if(!empty($search_valideur) && $search_valideur != -1) {
$filter.= " AND cp.fk_validator = '".$db->escape($search_valideur)."'\n";
}
// STATUT
// Type
if (!empty($search_type) && $search_type != -1) {
$filter.= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
}
// Status
if(!empty($search_statut) && $search_statut != -1) {
$filter.= " AND cp.statut = '".$db->escape($search_statut)."'\n";
}
@ -194,7 +199,6 @@ if (!empty($sall))
if (empty($user->rights->holiday->read_all)) $filter.=' AND cp.fk_user IN ('.join(',',$childids).')';
if ($type > 0) $filter.=' AND cp.fk_type IN ('.$db->escape($type).')';
// Récupération de l'ID de l'utilisateur
$user_id = $user->id;
@ -297,34 +301,34 @@ if ($sall)
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// FILTRES
// Filters
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="4" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
// DATE CREATE
// Create date
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_create" value="'.dol_escape_htmltag($month_create).'">';
$formother->select_year($year_create,'year_create',1, $min_year, 0);
print '</td>';
// UTILISATEUR
// User
if ($user->rights->holiday->write_all)
{
print '<td class="liste_titre maxwidthonsmartphone" align="left">';
print $form->select_dolusers($search_employe,"search_employe",1,"",0,'','',0,0,0,'',0,'','maxwidth200');
print $form->select_dolusers($search_employee,"search_employee",1,"",0,'','',0,0,0,'',0,'','maxwidth200');
print '</td>';
}
else
{
//print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre maxwidthonsmartphone" align="left">';
print $form->select_dolusers($user->id,"search_employe",1,"",1,'','',0,0,0,'',0,'','maxwidth200');
print $form->select_dolusers($user->id,"search_employee",1,"",1,'','',0,0,0,'',0,'','maxwidth200');
print '</td>';
}
// APPROVER
// Approve
if($user->rights->holiday->write_all)
{
print '<td class="liste_titre maxwidthonsmartphone" align="left">';
@ -352,30 +356,30 @@ foreach($typeleaves as $key => $val)
//$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
$arraytypeleaves[$val['rowid']]=$labeltoshow;
}
print $form->selectarray('type', $arraytypeleaves, (GETPOST('type')?GETPOST('type'):''), 1);
print $form->selectarray('search_type', $arraytypeleaves, (GETPOST('search_type')?GETPOST('search_type'):''), 1);
print '</td>';
// DUREE
// Duration
print '<td class="liste_titre">&nbsp;</td>';
// DATE DEBUT
// Start date
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_start" value="'.dol_escape_htmltag($month_start).'">';
$formother->select_year($year_start,'year_start',1, $min_year, $max_year);
print '</td>';
// DATE FIN
// End date
print '<td class="liste_titre" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.dol_escape_htmltag($month_end).'">';
$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
print '</td>';
// STATUT
// Status
print '<td class="liste_titre maxwidthonsmartphone maxwidth200" align="right">';
$holiday->selectStatutCP($search_statut);
print '</td>';
// ACTION
// Actions
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto;
@ -404,7 +408,7 @@ if (! empty($holiday->holiday))
foreach($holiday->holiday as $infos_CP)
{
// Utilisateur
// User
$userstatic->id=$infos_CP['fk_user'];
$userstatic->lastname=$infos_CP['user_lastname'];
$userstatic->firstname=$infos_CP['user_firstname'];
@ -412,7 +416,7 @@ if (! empty($holiday->holiday))
$userstatic->statut=$infos_CP['user_statut'];
$userstatic->photo=$infos_CP['user_photo'];
// Valideur
// Validator
$approbatorstatic->id=$infos_CP['fk_validator'];
$approbatorstatic->lastname=$infos_CP['validator_lastname'];
$approbatorstatic->firstname=$infos_CP['validator_firstname'];

View File

View File

@ -70,6 +70,10 @@ ALTER TABLE llx_extrafields ADD COLUMN fielddefault varchar(255);
ALTER TABLE llx_c_typent MODIFY COLUMN libelle varchar(64);
ALTER TABLE llx_holiday ADD COLUMN ref varchar(30) NULL;
ALTER TABLE llx_holiday ADD COLUMN ref_ext varchar(255);
create table llx_notify_def_object
(
id integer AUTO_INCREMENT PRIMARY KEY,
@ -346,7 +350,7 @@ ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_tx d
ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price double(24,8) DEFAULT NULL;
ALTER TABLE llx_product_fournisseur_price_log ADD COLUMN multicurrency_price_ttc double(24,8) DEFAULT NULL;
UPDATE TABLE llx_contrat set ref = rowid where ref is null or ref = '';
UPDATE llx_contrat set ref = rowid where ref is null or ref = '';
create table llx_payment_various
(

View File

@ -19,6 +19,8 @@
CREATE TABLE llx_holiday
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL, -- number
ref_ext varchar(255),
entity integer DEFAULT 1 NOT NULL, -- Multi company id
fk_user integer NOT NULL,
fk_user_create integer,

View File

@ -41,11 +41,15 @@ $action=GETPOST('action', 'alpha');
// Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install
// or MAIN_VERSION_LAST_UPGRADE for upgrade.
$targetversion=DOL_VERSION; // It it's last upgrade
$targetversion=DOL_VERSION; // If it's latest upgrade
if (! empty($action) && preg_match('/upgrade/i', $action)) // If it's an old upgrade
{
$tmp=explode('_', $action, 2);
if ($tmp[0]=='upgrade' && ! empty($tmp[1])) $targetversion=$tmp[1];
if ($tmp[0]=='upgrade')
{
//if (! empty($tmp[1])) $targetversion=$tmp[1];
$targetversion=$versionto;
}
}
$langs->load("admin");

View File

@ -75,6 +75,9 @@ InterventionSentByEMail=Intervention %s sent by EMail
ProposalDeleted=Proposal deleted
OrderDeleted=Order deleted
InvoiceDeleted=Invoice deleted
PRODUCT_CREATEInDolibarr=Product %s created
PRODUCT_MODIFYInDolibarr=Product %s modified
PRODUCT_DELETEInDolibarr=Product %s deleted
##### End agenda events #####
AgendaModelModule=Document templates for event
DateActionStart=Start date

View File

@ -358,6 +358,7 @@ TotalLT1ES=Total RE
TotalLT2ES=Total IRPF
HT=Net of tax
TTC=Inc. tax
INCT=Inc. all taxes
VAT=Sales tax
VATs=Sales taxes
LT1ES=RE

View File

@ -26,8 +26,8 @@ ProductOrService=Product or Service
ProductsAndServices=Products and Services
ProductsOrServices=Products or Services
ProductsOnSaleOnly=Products for sale only
ProductsOnPurchaseOnly=Product for purchase only
ProductsNotOnSell=Product not for sale and not for purchase
ProductsOnPurchaseOnly=Products for purchase only
ProductsNotOnSell=Products not for sale and not for purchase
ProductsOnSellAndOnBuy=Products for sale and for purchase
ServicesOnSaleOnly=Services for sale only
ServicesOnPurchaseOnly=Services for purchase only

View File

@ -43,3 +43,4 @@ NotTheGoodQualitySupplier=Wrong quality
ReputationForThisProduct=Reputation
BuyerName=Buyer name
AllProductServicePrices=All product / service prices
BuyingPriceNumShort=Supplier prices

View File

@ -433,7 +433,7 @@ class MyObject extends CommonObject
global $user;
$error = 0;
$object = new MyModuleObject($this->db);
$object = new self($this->db);
$this->db->begin();

0
htdocs/modulebuilder/template/scripts/myobject.php Executable file → Normal file
View File

View File

@ -2136,11 +2136,12 @@ class Product extends CommonObject
/**
* Charge tableau des stats commande client pour le produit/service
*
* @param int $socid Id societe pour filtrer sur une societe
* @param int $filtrestatut Id statut pour filtrer sur un statut
* @return array Array of stats (nb=nb of order, qty=qty ordered)
* @param int $socid Id societe pour filtrer sur une societe
* @param string $filtrestatut Id statut pour filtrer sur un statut
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
* @return array Array of stats (nb=nb of order, qty=qty ordered)
*/
function load_stats_commande($socid=0,$filtrestatut='')
function load_stats_commande($socid=0,$filtrestatut='', $forVirtualStock = 0)
{
global $conf,$user;
@ -2149,12 +2150,12 @@ class Product extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.rowid = cd.fk_commande";
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity IN (".getEntity('commande').")";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")";
@ -2202,11 +2203,12 @@ class Product extends CommonObject
/**
* Charge tableau des stats commande fournisseur pour le produit/service
*
* @param int $socid Id societe pour filtrer sur une societe
* @param string $filtrestatut Id des statuts pour filtrer sur des statuts
* @return array Tableau des stats
* @param int $socid Id societe pour filtrer sur une societe
* @param string $filtrestatut Id des statuts pour filtrer sur des statuts
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
* @return array Tableau des stats
*/
function load_stats_commande_fournisseur($socid=0,$filtrestatut='')
function load_stats_commande_fournisseur($socid=0,$filtrestatut='', $forVirtualStock = 0)
{
global $conf,$user;
@ -2215,12 +2217,12 @@ class Product extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd";
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.rowid = cd.fk_commande";
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity IN (".getEntity('supplier_order').")";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND c.fk_soc = ".$socid;
if ($filtrestatut != '') $sql.= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0
@ -2244,11 +2246,12 @@ class Product extends CommonObject
/**
* Charge tableau des stats expedition client pour le produit/service
*
* @param int $socid Id societe pour filtrer sur une societe
* @param int $filtrestatut Id statut pour filtrer sur un statut
* @return array Tableau des stats
* @param int $socid Id societe pour filtrer sur une societe
* @param string $filtrestatut Id statut pour filtrer sur un statut
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
* @return array Tableau des stats
*/
function load_stats_sending($socid=0,$filtrestatut='')
function load_stats_sending($socid=0,$filtrestatut='', $forVirtualStock = 0)
{
global $conf,$user;
@ -2259,14 +2262,14 @@ class Product extends CommonObject
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
$sql.= ", ".MAIN_DB_PREFIX."expedition as e";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE e.rowid = ed.fk_expedition";
$sql.= " AND c.rowid = cd.fk_commande";
$sql.= " AND e.fk_soc = s.rowid";
$sql.= " AND e.entity IN (".getEntity('expedition').")";
$sql.= " AND ed.fk_origin_line = cd.rowid";
$sql.= " AND cd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND e.fk_soc = ".$socid;
if ($filtrestatut <> '') $sql.= " AND c.fk_statut in (".$filtrestatut.")";
@ -2290,11 +2293,12 @@ class Product extends CommonObject
/**
* Charge tableau des stats réception fournisseur pour le produit/service
*
* @param int $socid Id societe pour filtrer sur une societe
* @param int $filtrestatut Id statut pour filtrer sur un statut
* @return array Tableau des stats
* @param int $socid Id societe pour filtrer sur une societe
* @param string $filtrestatut Id statut pour filtrer sur un statut
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
* @return array Tableau des stats
*/
function load_stats_reception($socid=0,$filtrestatut='')
function load_stats_reception($socid=0,$filtrestatut='', $forVirtualStock = 0)
{
global $conf,$user;
@ -2303,12 +2307,12 @@ class Product extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd";
$sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE cf.rowid = fd.fk_commande";
$sql.= " AND cf.fk_soc = s.rowid";
$sql.= " AND cf.entity IN (".getEntity('supplier_order').")";
$sql.= " AND fd.fk_product = ".$this->id;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) $sql.= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid > 0) $sql.= " AND cf.fk_soc = ".$socid;
if ($filtrestatut <> '') $sql.= " AND cf.fk_statut in (".$filtrestatut.")";
@ -3801,23 +3805,23 @@ class Product extends CommonObject
if (! empty($conf->commande->enabled))
{
$result=$this->load_stats_commande(0,'1,2');
$result=$this->load_stats_commande(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_client=$this->stats_commande['qty'];
}
if (! empty($conf->expedition->enabled))
{
$result=$this->load_stats_sending(0,'1,2');
$result=$this->load_stats_sending(0,'1,2', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_sending_client=$this->stats_expedition['qty'];
}
if (! empty($conf->fournisseur->enabled))
{
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4');
$result=$this->load_stats_commande_fournisseur(0,'1,2,3,4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
$result=$this->load_stats_reception(0,'4');
$result=$this->load_stats_reception(0,'4', 1);
if ($result < 0) dol_print_error($this->db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty'];
}

View File

@ -164,6 +164,8 @@ $arrayfields=array(
'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))),
'p.sellprice'=>array('label'=>$langs->trans("SellingPrice"), 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)),
'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))),
'p.numbuyprice'=>array('label'=>$langs->trans("BuyingPriceNumShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))),
'p.pmp'=>array('label'=>$langs->trans("PMPValueShort"), 'checked'=>0, 'enabled'=>(! empty($user->rights->fournisseur->lire))),
'p.seuil_stock_alerte'=>array('label'=>$langs->trans("StockLimit"), 'checked'=>0, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')),
'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')),
'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')),
@ -266,7 +268,7 @@ else
$sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
$sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,';
$sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy,';
$sql.= ' p.datec as date_creation, p.tms as date_update,';
$sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,';
//$sql.= ' pfp.ref_fourn as ref_supplier, ';
$sql.= ' MIN(pfp.unitprice) as minsellprice';
if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) {
@ -335,7 +337,7 @@ else
$sql.=$hookmanager->resPrint;
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,";
$sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
$sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy';
$sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy, p.pmp';
if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) {
$sql .= ', pac.rowid';
}
@ -563,6 +565,20 @@ else
print '<td class="liste_titre">';
print '&nbsp;';
print '</td>';
}
// Number buying Price
if (! empty($arrayfields['p.numbuyprice']['checked']))
{
print '<td class="liste_titre">';
print '&nbsp;';
print '</td>';
}
// WAP
if (! empty($arrayfields['p.pmp']['checked']))
{
print '<td class="liste_titre">';
print '&nbsp;';
print '</td>';
}
// Limit for alert
if (! empty($arrayfields['p.seuil_stock_alerte']['checked']))
@ -640,6 +656,8 @@ else
if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.numbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.numbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.pmp']['checked'])) print_liste_field_titre($arrayfields['p.pmp']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.seuil_stock_alerte']['checked'])) print_liste_field_titre($arrayfields['p.seuil_stock_alerte']['label'], $_SERVER["PHP_SELF"],"p.seuil_stock_alerte","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder);
@ -706,6 +724,7 @@ else
$product_static->status_buy = $obj->tobuy;
$product_static->status = $obj->tosell;
$product_static->entity = $obj->entity;
$product_static->pmp = $obj->pmp;
if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock
{
@ -809,6 +828,29 @@ else
if (! $i) $totalarray['nbfield']++;
}
// Number of buy prices
if (! empty($arrayfields['p.numbuyprice']['checked']))
{
print '<td align="right">';
if ($obj->tobuy)
{
if (($productFournList = $product_fourn->list_product_fournisseur_price($product_fourn->id)) > 0)
{
$htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList);
print $form->textwithpicto(count($productFournList),$htmltext);
}
}
print '</td>';
}
// WAP
if (! empty($arrayfields['p.pmp']['checked']))
{
print '<td class="nowrap" align="right">';
print price($product_static->pmp, 1, $langs);
print '</td>';
}
// Limit alert
if (! empty($arrayfields['p.seuil_stock_alerte']['checked']))
{

View File

@ -33,6 +33,7 @@
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_expression.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php';
@ -759,12 +760,8 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print '<td style="text-align: right">'.$langs->trans("MinPrice").'</td>';
print '</tr>';
$var=True;
for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{
$var = ! $var;
print '<tr class="oddeven">';
// Label of price
@ -1244,11 +1241,8 @@ if ($action == 'edit_price' && $object->getRights()->creer)
print '<tbody>';
$var = false;
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++)
{
$var = !$var;
print '<tr class="oddeven">';
print '<td>';
print $form->textwithpicto($langs->trans('SellingPrice') . ' ' . $i, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
@ -1389,13 +1383,12 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_
$notfirstlineforlevel=array();
$var = True;
$i = 0;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var = ! $var;
print '<tr '. $bc[$var].'>';
print '<tr class="oddeven">';
// Date
print "<td>" . dol_print_date($db->jdate($objp->dp), "dayhour") . "</td>";
@ -1440,7 +1433,9 @@ if ((empty($conf->global->PRODUIT_CUSTOMER_PRICES) || $action=='showlog_default_
print '<td align="right"></td>';
}
}
print '<td align="right">' . ($objp->price_base_type != 'TTC' ? price($objp->price_min) : '') . '</td>';
print '<td align="right">' . ($objp->price_base_type == 'TTC' ? price($objp->price_min_ttc) : '') . '</td>';
// User
@ -1611,9 +1606,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="update_customer_price_confirm">';
print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">';
dol_fiche_head();
print '<table class="border" width="100%">';
print '<tr>';
print '<td>' . $langs->trans('ThirdParty') . '</td>';
print '<td class="titlefield">' . $langs->trans('ThirdParty') . '</td>';
$staticsoc = new Societe($db);
$staticsoc->fetch($prodcustprice->fk_soc);
print "<td colspan='2'>" . $staticsoc->getNomUrl(1) . "</td>";
@ -1625,7 +1623,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '</td></tr>';
// Price base
print '<tr><td width="15%">';
print '<tr><td>';
print $langs->trans('PriceBase');
print '</td>';
print '<td>';
@ -1634,7 +1632,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '</tr>';
// Price
print '<tr><td width="20%">';
print '<tr><td>';
$text = $langs->trans('SellingPrice');
print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1);
print '</td><td>';
@ -1663,7 +1661,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '</tr>';
// Update all child soc
print '<tr><td width="15%">';
print '<tr><td>';
print $langs->trans('ForceUpdateChildPriceSoc');
print '</td>';
print '<td>';
@ -1673,7 +1671,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '</table>';
print '<br><div class="center">';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
@ -1683,7 +1683,10 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
}
elseif ($action == 'showlog_customer_price')
{
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int'));
// List of all log of prices by customers
print '<!-- list of all lof of prices per customer -->'."\n";
$filter = array('t.fk_product' => $object->id,'t.fk_soc' => GETPOST('socid', 'int'));
// Count total nb of records
$nbtotalofrecords = '';
@ -1710,7 +1713,6 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
if (count($prodcustprice->lines) > 0)
{
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
@ -1723,31 +1725,53 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '<td align="right">' . $langs->trans("VATRate") . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("TTC") . '</td>';
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '<td align="right">' . $langs->trans("INCT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$var = True;
foreach ($prodcustprice->lines as $line)
{
$var = ! $var;
print '<tr class="oddeven">';
// Date
$staticsoc = new Societe($db);
$staticsoc->fetch($line->fk_soc);
print "<td>" . $staticsoc->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
// Date
$staticsoc = new Societe($db);
$staticsoc->fetch($line->fk_soc);
$tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx;
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
// Line for default price
if ($line->price_base_type=='HT')
{
$pu=$line->price;
}
else
{
$pu=$line->price_ttc;
}
// Local tax is not saved into table of product. We use value linked to VAT code.
$localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc);
// Define part of HT, VAT, TTC
$resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
// Calcul du total ht sans remise
$total_ht = $resultarray[0];
$total_vat = $resultarray[1];
$total_localtax1 = $resultarray[9];
$total_localtax2 = $resultarray[10];
$total_ttc = $resultarray[2];
print '<tr class="oddeven">';
print "<td>" . $staticsoc->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '<td align="right">' . price($resultarray[2]) . '</td>';
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
@ -1757,6 +1781,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '<td align="right">';
print $userstatic->getLoginUrl(1);
print '</td>';
print '</tr>';
}
print "</table>";
} else {
@ -1766,7 +1791,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
else if ($action != 'showlog_default_price' && $action != 'edit_price')
{
// List of all prices by customers
print '<!-- list of prices per customer -->'."\n";
print '<!-- list of all prices per customer -->'."\n";
// Count total nb of records
$nbtotalofrecords = '';
@ -1788,24 +1813,14 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("ThirdParty") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
print '<td align="right">' . $langs->trans("VATRate") . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
if (count($prodcustprice->lines) > 0 || $search_soc)
{
$colspan=8;
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") $colspan++;
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
print '<td class="liste_titre" colspan="8">&nbsp;</td>';
print '<td class="liste_titre" colspan="'.$colspan.'">&nbsp;</td>';
// Print the search button
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
@ -1814,10 +1829,41 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '</tr>';
}
$var = False;
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("ThirdParty") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
print '<td align="center">' . $langs->trans("PriceBase") . '</td>';
print '<td align="right">' . $langs->trans("VATRate") . '</td>';
print '<td align="right">' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("TTC") . '</td>';
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '<td align="right">' . $langs->trans("INCT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>';
print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>';
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// Line for default price
if ($object->price_base_type=='HT')
{
$pu=$object->price;
}
else
{
$pu=$object->price_ttc;
}
// Local tax is not saved into table of product. We use value linked to VAT code.
$localtaxarray=getLocalTaxesFromRate($object->tva_tx.($object->default_vat_code?' ('.$object->default_vat_code.')':''), 0, $mysoc, $mysoc);
// Define part of HT, VAT, TTC
$resultarray=calcul_price_total(1, $pu, 0, $object->tva_tx, 1, 1, 0, $object->price_base_type, $object->recuperableonly, $object->type, $mysoc, $localtaxarray);
// Calcul du total ht sans remise
$total_ht = $resultarray[0];
$total_vat = $resultarray[1];
$total_localtax1 = $resultarray[9];
$total_localtax2 = $resultarray[10];
$total_ttc = $resultarray[2];
print '<tr class="oddeven">';
print "<td>" . $langs->trans("Default") . "</td>";
print "<td>" . "</td>";
@ -1827,8 +1873,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print vatrate($object->tva_tx, true, $object->recuperableonly);
print $object->default_vat_code?' ('.$object->default_vat_code.')':'';
print "</td>";
print '<td align="right">' . price($object->price) . "</td>";
print '<td align="right">' . price($object->price_ttc) . "</td>";
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '<td align="right">' . price($resultarray[2]) . '</td>';
print '<td align="right">' . price($object->price_min) . '</td>';
print '<td align="right">' . price($object->price_min_ttc) . '</td>';
print '<td align="right">';
@ -1851,19 +1901,37 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
if (count($prodcustprice->lines) > 0)
{
$var = false;
foreach ($prodcustprice->lines as $line)
{
$var = ! $var;
print '<tr class="oddeven">';
// Date
$staticsoc = new Societe($db);
$staticsoc->fetch($line->fk_soc);
$tva_tx = $line->default_vat_code ? $line->tva_tx.' ('.$line->default_vat_code.')' : $line->tva_tx;
// Line for default price
if ($line->price_base_type=='HT')
{
$pu=$line->price;
}
else
{
$pu=$line->price_ttc;
}
// Local tax is not saved into table of product. We use value linked to VAT code.
$localtaxarray=getLocalTaxesFromRate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), 0, $staticsoc, $mysoc);
// Define part of HT, VAT, TTC
$resultarray=calcul_price_total(1, $pu, 0, $line->tva_tx, 1, 1, 0, $line->price_base_type, $line->recuperableonly, $object->type, $mysoc, $localtaxarray);
// Calcul du total ht sans remise
$total_ht = $resultarray[0];
$total_vat = $resultarray[1];
$total_localtax1 = $resultarray[9];
$total_localtax2 = $resultarray[10];
$total_ttc = $resultarray[2];
print '<tr class="oddeven">';
print "<td>" . $staticsoc->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
@ -1871,6 +1939,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
print '<td align="right">' . vatrate($tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") print '<td align="right">' . price($resultarray[2]) . '</td>';
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';

View File

@ -232,7 +232,7 @@ if ($resql)
$moreforfilter.='</div>';
}
//$moreforfilter.=$langs->trans("StockTooLow").' <input type="checkbox" name="toolowstock" value="1"'.($toolowstock?' checked':'').'>';
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
@ -257,7 +257,7 @@ if ($resql)
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">';
// Lignes des champs de filtre
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">';
@ -304,14 +304,14 @@ if ($resql)
print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"], "p.tobuy","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre('');
print "</tr>\n";
$product_static=new Product($db);
$warehousetmp=new Entrepot($db);
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
// Multilangs
if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
{
@ -335,20 +335,20 @@ if ($resql)
$product_static->label = $objp->label;
$product_static->type=$objp->fk_product_type;
$product_static->entity=$objp->entity;
$warehousetmp->id=$objp->fk_entrepot;
$warehousetmp->ref=$objp->warehouse_ref;
$warehousetmp->label=$objp->warehouse_ref;
$warehousetmp->fk_parent=$objp->warehouse_parent;
print '<tr>';
// Ref
print '<td class="nowrap">';
print $product_static->getNomUrl(1,'',16);
//if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow"));
print '</td>';
// Label
print '<td>'.$objp->label.'</td>';
@ -391,18 +391,6 @@ if ($resql)
print '</div>';
print '</form>';
if ($num > $conf->liste_limit)
{
if ($sref || $snom || $sall || GETPOST('search'))
{
print_barre_liste('', $page, "reassort.php", "&sref=".$sref."&snom=".$snom."&amp;sall=".$sall."&amp;tosell=".$tosell."&amp;tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, '');
}
else
{
print_barre_liste('', $page, "reassort.php", "&sref=$sref&snom=$snom&fourn_id=$fourn_id".(isset($type)?"&amp;type=$type":"")."&amp;tosell=".$tosell."&amp;tobuy=".$tobuy, $sortfield, $sortorder,'',$num, 0, '');
}
}
$db->free($resql);
}

View File

@ -655,7 +655,7 @@ if ($id > 0 || $ref)
{
if ($found) $helpondiff.='<br>'; else $found=1;
$helpondiff.=$langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty'];
$result=$object->load_stats_commande(0,'0');
$result=$object->load_stats_commande(0,'0', 1);
if ($result < 0) dol_print_error($db,$object->error);
$helpondiff.=' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')';
}
@ -664,7 +664,7 @@ if ($id > 0 || $ref)
if (! empty($conf->expedition->enabled))
{
if ($found) $helpondiff.='<br>'; else $found=1;
$result=$object->load_stats_sending(0,'2');
$result=$object->load_stats_sending(0,'2', 1);
$helpondiff.=$langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty'];
}
@ -672,9 +672,9 @@ if ($id > 0 || $ref)
if (! empty($conf->fournisseur->enabled))
{
if ($found) $helpondiff.='<br>'; else $found=1;
$result=$object->load_stats_commande_fournisseur(0,'3,4');
$result=$object->load_stats_commande_fournisseur(0,'3,4', 1);
$helpondiff.=$langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty'];
$result=$object->load_stats_commande_fournisseur(0,'0,1,2');
$result=$object->load_stats_commande_fournisseur(0,'0,1,2', 1);
if ($result < 0) dol_print_error($db,$object->error);
$helpondiff.=' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')';
}

View File

@ -991,7 +991,7 @@ class Project extends CommonObject
}
$linkclose='';
if (empty($notooltip) && $user->rights->propal->lire)
if (empty($notooltip) && $user->rights->projet->lire)
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{

View File

@ -882,8 +882,6 @@ class Societe extends CommonObject
$sql .= ', multicurrency_code = \''.$this->db->escape($this->multicurrency_code)."'";
$sql .= " WHERE rowid = '" . $id ."'";
dol_syslog(get_class($this)."::Update", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -978,11 +976,12 @@ class Societe extends CommonObject
{
// Doublon
$this->error = $langs->trans("ErrorDuplicateField");
$result = -1;
$result = -1;
}
else
{
$result = -2;
$this->error = $this->db->lasterror();
$result = -2;
}
$this->db->rollback();
return $result;

View File

@ -21,10 +21,11 @@
*/
/**
* \file htdocs/societe/price.php
* \file htdocs/societe/price.php
* \ingroup product
* \brief Page to show product prices by customer
* \brief Page to show product prices by customer
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
@ -42,7 +43,8 @@ $langs->load("companies");
$langs->load("bills");
$action = GETPOST('action', 'alpha');
$search_prod = GETPOST('search_prod');
$search_prod = GETPOST('search_prod','alpha');
$cancel = GETPOST('cancel','alpha');
// Security check
$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int');
@ -71,36 +73,72 @@ if (empty($reshook))
{
$search_prod = '';
}
if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) {
$update_child_soc = GETPOST('updatechildprice');
// add price by customer
$prodcustprice->fk_soc = $socid;
$prodcustprice->fk_product = GETPOST('prodid', 'int');
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
// We must define tva_tx, npr and local taxes
$vatratecode = '';
$tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
$npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
$localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0';
// If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes
if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg))
{
// We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price.
$vatratecode=$reg[1];
// Get record from code
$sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
$sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'";
$sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1";
$sql.= " AND t.code ='".$vatratecode."'";
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
$npr = $obj->recuperableonly;
$localtax1 = $obj->localtax1;
$localtax2 = $obj->localtax2;
$localtax1_type = $obj->localtax1_type;
$localtax2_type = $obj->localtax2_type;
}
}
$prodcustprice->default_vat_code = $vatratecode;
$prodcustprice->tva_tx = $tva_tx;
$prodcustprice->recuperableonly = $npr;
$prodcustprice->localtax1_tx = $localtax1;
$prodcustprice->localtax2_tx = $localtax2;
$prodcustprice->localtax1_type = $localtax1_type;
$prodcustprice->localtax2_type = $localtax2_type;
$result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} else {
setEventMessages($langs->trans('Save'), null, 'mesgs');
}
$action = '';
}
if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) {
// Delete price by customer
$prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user);
if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs');
} else {
@ -108,27 +146,27 @@ if (empty($reshook))
}
$action = '';
}
if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) {
$prodcustprice->fetch(GETPOST('lineid', 'int'));
$update_child_soc = GETPOST('updatechildprice');
// update price by customer
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} else {
setEventMessages($langs->trans('Save'), null, 'mesgs');
}
$action = '';
}
}
@ -154,7 +192,7 @@ dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), 0, 'company');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
@ -239,7 +277,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
// VAT
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr);
print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1);
print '</td></tr>';
// Price base
@ -299,7 +337,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print load_fiche_titre($langs->trans('PriceByCustomer'));
$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0)
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
@ -374,6 +412,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<br></form>';
} elseif ($action == 'showlog_customer_price') {
print '<!-- showlog_customer_price -->'."\n";
$filter = array (
't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid
);
@ -385,7 +425,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
}
$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0)
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
@ -440,8 +480,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</td>';
}
print "</table>";
}
else
}
else
{
print $langs->trans('None');
}
@ -449,8 +489,8 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print "\n" . '<div class="tabsAction">' . "\n";
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>';
print "\n</div><br>\n";
}
else
}
else
{
// View mode
@ -466,30 +506,32 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&amp;socid=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>';
}
print "\n</div>\n";
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter);
}
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
$option = '&search_prod=' . $search_prod . '&id=' . $object->id;
print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
print '<!-- view specific price for each product -->'."\n";
print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans("Product") . '</td>';
print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>';
@ -502,12 +544,12 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '<td align="right">' . $langs->trans("ChangedBy") . '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
if (count($prodcustprice->lines) > 0 || $search_prod)
{
print '<tr class="liste_titre">';
print '<td><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>';
print '<td colspan="8">&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>';
print '<td class="liste_titre" colspan="8">&nbsp;</td>';
// Print the search button
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
@ -515,35 +557,35 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</td>';
print '</tr>';
}
if (count($prodcustprice->lines) > 0)
{
$var = False;
foreach ($prodcustprice->lines as $line)
{
print "<tr " . $bc[$var] . ">";
$staticprod = new Product($db);
$staticprod->fetch($line->fk_product);
print "<td>" . $staticprod->getNomUrl(1) . "</td>";
print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
print '<td align="right">' . vatrate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), true, $line->recuperableonly) . "</td>";
print '<td align="right">' . price($line->price) . "</td>";
print '<td align="right">' . price($line->price_ttc) . "</td>";
print '<td align="right">' . price($line->price_min) . '</td>';
print '<td align="right">' . price($line->price_min_ttc) . '</td>';
// User
$userstatic = new User($db);
$userstatic->fetch($line->fk_user);
print '<td align="right">';
print $userstatic->getLoginUrl(1);
print '</td>';
// Action
if ($user->rights->produit->creer || $user->rights->service->creer)
{
@ -561,21 +603,21 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</a>';
print '</td>';
}
print "</tr>\n";
}
}
else
{
$colspan=9;
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1;
if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1;
print '<tr ' . $bc[false] . '><td colspan="'.$colspan.'">' . $langs->trans('None') . '</td></tr>';
}
print "</table>";
print "</form>";
}
}

View File

@ -506,7 +506,7 @@ class SupplierProposal extends CommonObject
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la propale meme
$result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
$result=$this->update_price(1,'auto',0,$this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();

View File

@ -132,21 +132,21 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
/*$tmp=dol_buildpath('/google/oauth2callback.php', 0);
var_dump($tmp);
*/
/*$tmp=dol_buildpath('/google/oauth2callback.php', 1);
var_dump($tmp);
*/
$result=dol_buildpath('/google/oauth2callback.php', 2);
print __METHOD__." result=".$result."\n";
$this->assertStringStartsWith('http', $result);
$result=dol_buildpath('/google/oauth2callback.php', 3);
print __METHOD__." result=".$result."\n";
$this->assertStringStartsWith('http', $result);
}
/**
* testGetBrowserInfo
*
@ -512,32 +512,48 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
// Default trunc (will add ... if truncation truncation or keep last char if only one char)
$input="éeéeéeàa";
$after=dol_trunc($input,3);
$this->assertEquals("éeé...",$after);
$this->assertEquals("éeé...",$after,'Test A1');
$after=dol_trunc($input,2);
$this->assertEquals("ée...",$after);
$this->assertEquals("ée...",$after,'Test A2');
$after=dol_trunc($input,1);
$this->assertEquals("é...",$after,'Test A3');
$input="éeéeé";
$after=dol_trunc($input,3);
$this->assertEquals("éeéeé",$after,'Test B1');
$after=dol_trunc($input,2);
$this->assertEquals("éeéeé",$after,'Test B2');
$after=dol_trunc($input,1);
$this->assertEquals("é...",$after,'Test B3');
$input="éeée";
$after=dol_trunc($input,3);
$this->assertEquals("éeée",$after,'Test C1');
$after=dol_trunc($input,2);
$this->assertEquals("éeée",$after,'Test C2');
$after=dol_trunc($input,1);
$this->assertEquals("éeée",$after,'Test C3');
$input="éeé";
$after=dol_trunc($input,3);
$this->assertEquals("éeé",$after);
$this->assertEquals("éeé",$after,'Test C');
$after=dol_trunc($input,2);
$this->assertEquals("éeé",$after);
$this->assertEquals("éeé",$after,'Test D');
$after=dol_trunc($input,1);
$this->assertEquals("é...",$after);
$this->assertEquals("é",$after,'Test E');
// Trunc with no ...
$input="éeéeéeàa";
$after=dol_trunc($input,3,'right','UTF-8',1);
$this->assertEquals("éeé",$after);
$this->assertEquals("éeé",$after,'Test F');
$after=dol_trunc($input,2,'right','UTF-8',1);
$this->assertEquals("ée",$after);
$this->assertEquals("ée",$after,'Test G');
$input="éeé";
$after=dol_trunc($input,3,'right','UTF-8',1);
$this->assertEquals("éeé",$after);
$this->assertEquals("éeé",$after,'Test H');
$after=dol_trunc($input,2,'right','UTF-8',1);
$this->assertEquals("ée",$after);
$this->assertEquals("ée",$after,'Test I');
$after=dol_trunc($input,1,'right','UTF-8',1);
$this->assertEquals("é",$after);
$this->assertEquals("é",$after,'Test J');
$input="éeéeéeàa";
$after=dol_trunc($input,4,'middle');
$this->assertEquals("ée...àa",$after);
$this->assertEquals("ée...àa",$after,'Test K');
return true;
}
@ -668,7 +684,7 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
$this->assertEquals("21 jump street\nMyTown, MyState, 99999",$address);
}
/**
* testDolFormatAddress
*
@ -681,18 +697,18 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$object=new Societe($db);
$object->initAsSpecimen();
$object->country_code='FR';
$phone=dol_print_phone('1234567890', $object->country_code);
$this->assertEquals('<span style="margin-right: 10px;">12&nbsp;34&nbsp;56&nbsp;78&nbsp;90</span>', $phone, 'Phone for FR 1');
$object->country_code='FR';
$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, '');
$this->assertEquals('<span style="margin-right: 10px;">1234567890</span>', $phone, 'Phone for FR 2');
$object->country_code='FR';
$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
$this->assertEquals('<span style="margin-right: 10px;">12 34 56 78 90</span>', $phone, 'Phone for FR 3');
@ -700,10 +716,10 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
$object->country_code='CA';
$phone=dol_print_phone('1234567890', $object->country_code, 0, 0, 0, ' ');
$this->assertEquals('<span style="margin-right: 10px;">(123) 456-7890</span>', $phone, 'Phone for CA 1');
}
/**
* testImgPicto
*
@ -1053,5 +1069,5 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase
return true;
}
}