Merge remote-tracking branch 'upstream/develop' into facturerec

This commit is contained in:
Frédéric FRANCE 2021-02-08 20:21:46 +01:00
commit 898bf55202
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
41 changed files with 3223 additions and 914 deletions

View File

@ -436,13 +436,12 @@ if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
if ($search_project) $sql .= natural_search('pr.title', $search_project);
if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->sanitize($db->escape($search_availability)).')';
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_societe_alias) $sql .= natural_search('s.name_alias', $search_societe_alias);
if ($search_login) $sql .= natural_search("u.login", $search_login);
@ -574,6 +573,12 @@ if ($resql)
if ($search_fk_cond_reglement > 0) $param .= '&search_fk_cond_reglement='.$search_fk_cond_reglement;
if ($search_fk_shipping_method > 0) $param .= '&search_fk_shipping_method='.$search_fk_shipping_method;
if ($search_fk_mode_reglement > 0) $param .= '&search_fk_mode_reglement='.$search_fk_mode_reglement;
if ($search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.$search_type_thirdparty;
if ($search_town) $param .= '&search_town='.$search_town;
if ($search_zip) $param .= '&search_zip='.$search_zip;
if ($search_state) $param .= '&search_state='.$search_state;
if ($search_town) $param .= '&search_town='.$search_town;
if ($search_country) $param .= '&search_country='.$search_country;
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -750,7 +755,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidth100onsmartphone" align="center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print ajax_combobox('search_type_thirdparty');
print '</td>';
}

View File

@ -263,7 +263,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// ThirdParty Type
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
$sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td></tr>';
// Category

View File

@ -489,7 +489,7 @@ if ($resql)
if ($search_zip != '') $param .= '&search_zip='.urlencode($search_zip);
if ($search_state != '') $param .= '&search_state='.urlencode($search_state);
if ($search_country != '') $param .= '&search_country='.urlencode($search_country);
if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category);
if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus);
if ($show_files) $param .= '&show_files='.urlencode($show_files);
@ -727,7 +727,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
// Date order

View File

@ -271,7 +271,7 @@ print '</td></tr>';
// ThirdParty Type
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
$sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td></tr>';
// Category

View File

@ -9,6 +9,8 @@
* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -41,6 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
@ -367,7 +370,7 @@ $donstatic = new Don($db);
$paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db);
$paymentscstatic = new PaymentSocialContribution($db);
$paymentvatstatic = new Tva($db);
$paymentvatstatic = new PaymentVAT($db);
$paymentsalstatic = new PaymentSalary($db);
$paymentdonationstatic = new PaymentDonation($db);
$paymentvariousstatic = new PaymentVarious($db);
@ -1211,7 +1214,8 @@ if ($resql)
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
print ' '.$paymentvatstatic->getNomUrl(2);
} elseif ($links[$key]['type'] == 'payment_salary')
}
elseif ($links[$key]['type'] == 'payment_salary')
{
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
@ -1273,7 +1277,10 @@ if ($resql)
{
} elseif ($links[$key]['type'] == 'sc')
{
} else {
}
elseif ($links[$key]['type'] == 'vat')
{
} else {
// Show link with label $links[$key]['label']
if (!empty($objp->label) && !empty($links[$key]['label'])) print ' - ';
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';

View File

@ -8,6 +8,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -355,14 +356,22 @@ if ($result)
print img_object($langs->trans('SocialContribution'), 'bill').' ';
print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : '');
print '</a>';
} elseif ($links[$key]['type'] == 'payment_sc') {
}
elseif ($links[$key]['type'] == 'vat') {
print '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('VATDeclaration'), 'bill').' ';
print $langs->trans("VATDeclaration").($links[$key]['label'] ? '&nbsp;'.$links[$key]['label'] : '');
print '</a>';
}
elseif ($links[$key]['type'] == 'payment_sc') {
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('Payment'), 'payment').' ';
print $langs->trans("SocialContributionPayment");
print '</a>';
} elseif ($links[$key]['type'] == 'payment_vat') {
print '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('VAT'), 'payment').' ';
}
elseif ($links[$key]['type'] == 'payment_vat') {
print '<a href="'.DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$links[$key]['url_id'].'">';
print img_object($langs->trans('VATPayment'), 'payment').' ';
print $langs->trans("VATPayment");
print '</a>';
} elseif ($links[$key]['type'] == 'payment_salary') {

View File

@ -494,7 +494,7 @@ if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_type_thirdparty != '' && $search_type_thirdparty != '-1') $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_company_alias) $sql .= natural_search('s.name_alias', $search_company_alias);
if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1);
@ -894,7 +894,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone" align="center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100');
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), 'maxwidth100', 1);
print '</td>';
}
// Payment mode

View File

@ -264,7 +264,7 @@ print '</td></tr>';
// ThirdParty Type
print '<tr><td>'.$langs->trans("ThirdPartyType").'</td><td>';
$sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam_typent, '', 1);
if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td></tr>';

View File

@ -0,0 +1,342 @@
<?php
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016-2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/paiement_charge.php
* \ingroup tax
* \brief Page to add payment of a tax
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array("banks", "bills"));
$chid = GETPOST("id", 'int');
$action = GETPOST('action', 'alpha');
$amounts = array();
// Security check
$socid = 0;
if ($user->socid > 0)
{
$socid = $user->socid;
}
/*
* Actions
*/
if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes'))
{
$error = 0;
if ($_POST["cancel"])
{
$loc = DOL_URL_ROOT.'/compta/tva/card.php?id='.$chid;
header("Location: ".$loc);
exit;
}
$datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int'));
if (!(GETPOST("paiementtype", 'int') > 0))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
$error++;
$action = 'create';
}
if ($datepaye == '')
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++;
$action = 'create';
}
if (!empty($conf->banque->enabled) && !(GETPOST("accountid", 'int') > 0))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors');
$error++;
$action = 'create';
}
if (!$error)
{
$paymentid = 0;
// Read possible payments
foreach ($_POST as $key => $value)
{
if (substr($key, 0, 7) == 'amount_')
{
$other_chid = substr($key, 7);
$amounts[$other_chid] = price2num(GETPOST($key));
}
}
if (count($amounts) <= 0)
{
$error++;
setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
$action = 'create';
}
if (!$error)
{
$db->begin();
// Create a line of payments
$paiement = new PaymentVAT($db);
$paiement->chid = $chid;
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Tableau de montant
$paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml');
$paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
$paiement->note = GETPOST("note", 'restricthtml');
$paiement->note_private = GETPOST("note", 'restricthtml');
if (!$error)
{
$paymentid = $paiement->create($user, (GETPOST('closepaidvat') == 'on' ? 1 : 0));
if ($paymentid < 0)
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action = 'create';
}
}
if (!$error)
{
$result = $paiement->addPaymentToBank($user, 'payment_vat', '(VATPayment)', GETPOST('accountid', 'int'), '', '');
if (!($result > 0))
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action = 'create';
}
}
if (!$error)
{
$db->commit();
$loc = DOL_URL_ROOT.'/compta/tva/card.php?id='.$chid;
header('Location: '.$loc);
exit;
}
else {
$db->rollback();
}
}
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
// Formulaire de creation d'un paiement de charge
if ($action == 'create')
{
$tva = new Tva($db);
$tva->fetch($chid);
$tva->accountid = $tva->fk_account ? $tva->fk_account : $tva->accountid;
$tva->paiementtype = $tva->type_payment;
$total = $tva->amount;
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
//Add js for AutoFill
print ' $(document).ready(function () {';
print ' $(".AutoFillAmount").on(\'click touchstart\', function(){
var amount = $(this).data("value");
document.getElementById($(this).data(\'rowid\')).value = amount ;
});';
print ' });'."\n";
print ' </script>'."\n";
}
print load_fiche_titre($langs->trans("DoPayment"));
print "<br>\n";
print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$chid.'">';
print '<input type="hidden" name="chid" value="'.$chid.'">';
print '<input type="hidden" name="action" value="add_payment">';
dol_fiche_head('', '');
print '<table class="border centpercent">';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td><a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
//print '<tr><td>'.$langs->trans("Type")."</td><td>".$tva->type_label."</td></tr>\n";
print '<tr><td>'.$langs->trans("Period")."</td><td>".dol_print_date($tva->datev, 'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$tva->label."</td></tr>\n";
/*print '<tr><td>'.$langs->trans("DateDue")."</td><td>".dol_print_date($tva->date_ech,'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount")."</td><td>".price($tva->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
$sql = "SELECT sum(p.amount) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p";
$sql .= " WHERE p.fk_tva = ".$chid;
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
$db->free();
}
/*print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td>'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("RemainderToPay").'</td><td>'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';*/
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
$datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int'));
$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (GETPOST("remonth", 'int') ? $datepaye : -1) : 0;
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
print "</td>";
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype", "int") : $tva->paiementtype, "paiementtype");
print "</td>\n";
print '</tr>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td>';
$form->select_comptes(GETPOST("accountid") ? GETPOST("accountid", "int") : $tva->accountid, "accountid", 0, '', 1); // Show opend bank account list
print '</td></tr>';
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n";
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '</table>';
dol_fiche_end();
/*
* Autres charges impayees
*/
$num = 1;
$i = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
//print '<td>'.$langs->trans("SocialContribution").'</td>';
print '<td class="left">'.$langs->trans("DateDue").'</td>';
print '<td class="right">'.$langs->trans("Amount").'</td>';
print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>';
print '<td class="right">'.$langs->trans("RemainderToPay").'</td>';
print '<td class="center">'.$langs->trans("Amount").'</td>';
print "</tr>\n";
$total = 0;
$totalrecu = 0;
while ($i < $num)
{
$objp = $tva;
print '<tr class="oddeven">';
if ($objp->datev > 0)
{
print '<td class="left">'.dol_print_date($objp->datev, 'day').'</td>'."\n";
}
else {
print "<td align=\"center\"><b>!!!</b></td>\n";
}
print '<td class="right">'.price($objp->amount)."</td>";
print '<td class="right">'.price($sumpaid)."</td>";
print '<td class="right">'.price($objp->amount - $sumpaid)."</td>";
print '<td class="center">';
if ($sumpaid <> $objp->amount)
{
$namef = "amount_".$objp->id;
$nameRemain = "remain_".$objp->id;
/* Disabled, we autofil the amount with remain to pay by default
if (!empty($conf->use_javascript_ajax)) {
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'");
} */
$remaintopay = $objp->amount - $sumpaid;
print '<input type=hidden class="sum_remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
print '<input type="text" class="right width100" name="'.$namef.'" id="'.$namef.'" value="'.$remaintopay.'">';
}
else {
print '-';
}
print "</td>";
print "</tr>\n";
$total += $objp->total;
$total_ttc += $objp->total_ttc;
$totalrecu += $objp->am;
$i++;
}
if ($i > 1)
{
// Print total
print '<tr class="oddeven">';
print '<td colspan="2" class="left">'.$langs->trans("Total").':</td>';
print '<td class="right"><b>'.price($total_ttc).'</b></td>';
print '<td class="right"><b>'.price($totalrecu).'</b></td>';
print '<td class="right"><b>'.price($total_ttc - $totalrecu).'</b></td>';
print '<td align="center">&nbsp;</td>';
print "</tr>\n";
}
print "</table>";
// Bouton Save payment
print '<br><div class="center"><input type="checkbox" checked name="closepaidvat"> '.$langs->trans("ClosePaidVATAutomatically");
print '<br><input type="submit" class="button" name="save" value="'.$langs->trans('ToMakePayment').'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>\n";
}
llxFooter();
$db->close();

View File

@ -0,0 +1,331 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/payment_vat/card.php
* \ingroup facture
* \brief Onglet payment of a social contribution
* \remarks Fichier presque identique a fournisseur/paiement/card.php
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('bills', 'banks', 'companies'));
// Security check
$id = GETPOST("id", 'int');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm');
if ($user->socid) $socid = $user->socid;
// TODO ajouter regle pour restreindre acces paiement
//$result = restrictedArea($user, 'facture', $id,'');
$object = new PaymentVAT($db);
if ($id > 0)
{
$result = $object->fetch($id);
if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
}
/*
* Actions
*/
// Delete payment
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer)
{
$db->begin();
$result = $object->delete($user);
if ($result > 0)
{
$db->commit();
header("Location: ".DOL_URL_ROOT."/compta/tva/payments.php?mode=tvaonly");
exit;
}
else {
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
}
// Validate social contribution
/*
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer)
{
$db->begin();
$result=$object->valide();
if ($result > 0)
{
$db->commit();
$factures=array(); // TODO Get all id of invoices linked to this payment
foreach($factures as $id)
{
$fac = new Facture($db);
$fac->fetch($id);
$outputlangs = $langs;
if (! empty($_REQUEST['lang_id']))
{
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$fac->generateDocument($fac->modelpdf, $outputlangs);
}
}
header('Location: card.php?id='.$object->id);
exit;
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
}
*/
/*
* View
*/
llxHeader();
$tva = new TVA($db);
$form = new Form($db);
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$id;
$head[$h][1] = $langs->trans("VATPayment");
$hselected = $h;
$h++;
/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id;
$head[$h][1] = $langs->trans("Info");
$h++;
*/
dol_fiche_head($head, $hselected, $langs->trans("VATPayment"), -1, 'payment');
/*
* Deletion confirmation of payment
*/
if ($action == 'delete')
{
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
}
/*
* Validation confirmation of payment
*/
/*
if ($action == 'valide')
{
$facid = $_GET['facid'];
print $form->formconfirm('card.php?id='.$object->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
}
*/
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/payments.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
// Ref
/*print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">';
print $form->showrefnav($object,'id','',1,'rowid','id');
print '</td></tr>';*/
// Date
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($object->datep, 'day').'</td></tr>';
// Mode
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
// Numero
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_paiement.'</td></tr>';
// Montant
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
// Note
print '<tr><td>'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($object->note).'</td></tr>';
// Bank account
if (!empty($conf->banque->enabled))
{
if ($object->bank_account)
{
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print $bankline->getNomUrl(1, 0, 'showall');
print '</td>';
print '</tr>';
}
}
print '</table>';
print '</div>';
dol_fiche_end();
/*
* List of social contributions payed
*/
$disable_delete = 0;
$sql = 'SELECT f.rowid as scid, f.label as label, f.paye, f.amount as tva_amount, pf.amount';
//$sql .= ', pc.libelle as sc_type';
$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_vat as pf,'.MAIN_DB_PREFIX.'tva as f';
//$sql .= ', '.MAIN_DB_PREFIX.'c_chargesociales as pc';
$sql .= ' WHERE pf.fk_tva = f.rowid';
//$sql .= ' AND f.fk_type = pc.id';
$sql .= ' AND f.entity = '.$conf->entity;
$sql .= ' AND pf.rowid = '.$object->id;
dol_syslog("compta/payment_vat/card.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
print '<br><table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('VATDeclaration').'</td>';
//print '<td>'.$langs->trans('Type').'</td>';
print '<td>'.$langs->trans('Label').'</td>';
print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
print '<td class="center">'.$langs->trans('Status').'</td>';
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
print "</tr>\n";
if ($num > 0)
{
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
// Ref
print '<td>';
$tva->fetch($objp->scid);
print $tva->getNomUrl(1);
print "</td>\n";
// Type
/* print '<td>';
print $tva->type_label;4
print "</td>\n";*/
// Label
print '<td>'.$objp->label.'</td>';
// Expected to pay
print '<td class="right">'.price($objp->tva_amount).'</td>';
// Status
print '<td class="center">'.$tva->getLibStatut(4, $objp->amount).'</td>';
// Amount payed
print '<td class="right">'.price($objp->amount).'</td>';
print "</tr>\n";
if ($objp->paye == 1) // If at least one invoice is paid, disable delete
{
$disable_delete = 1;
}
$total = $total + $objp->amount;
$i++;
}
}
print "</table>\n";
$db->free($resql);
}
else {
dol_print_error($db);
}
/*
* Boutons Actions
*/
print '<div class="tabsAction">';
/*
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{
if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
{
if ($user->rights->facture->paiement)
{
print '<a class="butAction" href="card.php?id='.$_GET['id'].'&amp;facid='.$objp->facid.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
}
}
}
*/
if ($action == '')
{
if ($user->rights->tax->charges->supprimer)
{
if (!$disable_delete)
{
print '<a class="butActionDelete" href="card.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentVATPaid")).'">'.$langs->trans('Delete').'</a>';
}
}
}
print '</div>';
// End of page
llxFooter();
$db->close();

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -27,15 +28,23 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
if (!empty($conf->accounting->enabled)) {
include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array('compta', 'banks', 'bills'));
$id = GETPOST("id", 'int');
$action = GETPOST("action", "alpha");
$confirm = GETPOST('confirm');
$refund = GETPOST("refund", "int");
$auto_create_payment = GETPOST("auto_create_paiement", "int");
if (empty($refund)) $refund = 0;
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
@ -73,32 +82,71 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer)
if ($action == 'setdatev' && $user->rights->tax->charges->creer)
{
$object->fetch($id);
$object->datev = $datev;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
$object->fetch($id);
$object->datev = $datev;
$result = $object->update($user);
if ($result < 0) dol_print_error($db, $object->error);
$action = '';
$action = '';
}
// payment mode
if ($action == 'setmode' && $user->rights->tax->charges->creer) {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
// Bank account
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
$object->fetch($id);
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Classify paid
if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes')
{
$object->fetch($id);
$result = $object->set_paid($user);
}
if ($action == 'reopen' && $user->rights->tax->charges->creer) {
$result = $object->fetch($id);
if ($object->paye)
{
$result = $object->set_unpaid($user);
if ($result > 0)
{
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$error = 0;
$error = 0;
$object->accountid = GETPOST("accountid", 'int');
$object->type_payment = GETPOST("type_payment", 'alphanohtml');
$object->fk_account = GETPOST("accountid", 'int');
$object->type_payment = GETPOST("type_payment", 'alphanohtml');
$object->num_payment = GETPOST("num_payment", 'alphanohtml');
$object->datev = $datev;
$object->datep = $datep;
$object->datep = $datep;
$amount = price2num(GETPOST("amount", 'alpha'));
if ($refund == 1) {
$amount = -$amount;
}
$object->amount = $amount;
$object->amount = $amount;
$object->label = GETPOST("label", 'alpha');
$object->note_private = GETPOST("note", 'restricthtml');
$object->note = GETPOST("note", 'none');
if (empty($object->datep))
{
@ -110,7 +158,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PeriodEndDate")), null, 'errors');
$error++;
}
if (empty($object->type_payment) || $object->type_payment < 0)
if (!empty($auto_create_payment) && (empty($object->type_payment) || $object->type_payment < 0))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++;
@ -120,38 +168,81 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
$error++;
}
if (!empty($auto_create_payment) && ($object->fk_account <= 0))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountToCredit")), null, 'errors');
$error++;
}
if (!$error)
{
$db->begin();
$ret = $object->create($user);
if ($ret < 0) $error++;
$ret = $object->addPayment($user);
if ($ret > 0)
// Auto create payment
if (!empty($auto_create_payment) && !$error)
{
$db->commit();
header("Location: list.php");
$db->begin();
// Create a line of payments
$paiement = new PaymentVAT($db);
$paiement->chid = $object->id;
$paiement->datepaye = $datep;
$paiement->amounts = array($object->id=>$amount); // Tableau de montant
$paiement->paiementtype = GETPOST("type_payment", 'alphanohtml');
$paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
$paiement->note = GETPOST("note", 'none');
if (!$error)
{
$paymentid = $paiement->create($user, (int) GETPOST('closepaidtva'));
if ($paymentid < 0)
{
$error++;
setEventMessages($paiement->error, null, 'errors');
$action = 'create';
}
}
if (!$error)
{
$result = $paiement->addPaymentToBank($user, 'payment_vat', '(VATPayment)', GETPOST('accountid', 'int'), '', '');
if (!($result > 0))
{
$error++;
setEventMessages($paiement->error, null, 'errors');
}
}
if (!$error)
{
$db->commit();
}
else {
$db->rollback();
}
}
if (empty($error)) {
header("Location: card.php?id=" . $object->id);
exit;
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$action = "create";
}
}
$action = 'create';
}
if ($action == 'delete')
if ($action == 'confirm_delete' && $confirm == 'yes')
{
$result = $object->fetch($id);
$result = $object->fetch($id);
$totalpaye = $object->getSommePaiement();
if ($object->rappro == 0)
if (empty($totalpaye))
{
$db->begin();
$db->begin();
$ret = $object->delete($user);
if ($ret > 0)
{
$ret = $object->delete($user);
if ($ret > 0)
{
if ($object->fk_bank)
{
$accountline = new AccountLine($db);
@ -164,21 +255,99 @@ if ($action == 'delete')
$db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/tva/list.php');
exit;
} else {
}
else {
$object->error = $accountline->error;
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
$mesg = 'Error try do delete a line linked to a conciliated bank transaction';
setEventMessages($mesg, null, 'errors');
}
else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}
else {
setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors');
}
}
if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer)
{
$amount = price2num(GETPOST('amount'));
if (empty($amount))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
$action = 'edit';
}
elseif (!is_numeric($amount))
{
setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors');
$action = 'create';
}
else {
$result = $object->fetch($id);
$object->amount = price2num($amount);
$result = $object->update($user);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
// Action clone object
if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; }
if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer))
{
$db->begin();
$originalId = $id;
$object->fetch($id);
if ($object->id > 0)
{
$object->paye = 0;
$object->id = $object->ref = null;
if (GETPOST('clone_label', 'alphanohtml')) {
$object->label = GETPOST('clone_label', 'alphanohtml');
}
else {
$object->label = $langs->trans("CopyOf").' '.$object->label;
}
$newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int'));
if ($newdateperiod) $object->datev = $newdateperiod;
//if ($object->check()) {
$id = $object->create($user);
if ($id > 0)
{
$db->commit();
$db->close();
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else {
$id = $originalId;
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
//}
}
else {
$db->rollback();
dol_print_error($db, $object->error);
}
}
/*
* View
@ -205,11 +374,10 @@ if ($id)
if ($action == 'create')
{
print load_fiche_titre($langs->trans("VAT").' - '.$langs->trans("New"));
if (!empty($conf->use_javascript_ajax))
{
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
{
print "\n".'<script type="text/javascript" language="javascript">';
print '$(document).ready(function () {
$("#radiopayment").click(function() {
$("#label").val($(this).data("label"));
@ -218,44 +386,68 @@ if ($action == 'create')
$("#label").val($(this).data("label"));
});
});';
$("#auto_create_paiement").click(function() {
if($(this).is(":checked")) {
$("#label_fk_account").addClass("fieldrequired");
$("#label_type_payment").addClass("fieldrequired");
$(".hide_if_no_auto_create_payment").show();
} else {
$("#label_fk_account").removeClass("fieldrequired");
$("#label_type_payment").removeClass("fieldrequired");
$(".hide_if_no_auto_create_payment").hide();
}
});';
if ($_REQUEST['action'] === 'add') { // form has been send but there is at least one error
if (empty($auto_create_payment)) {
print '$("#label_fk_account").removeClass("fieldrequired");
$("#label_type_payment").removeClass("fieldrequired");
$(".hide_if_no_auto_create_payment").hide();';
} else {
print '$("#label_fk_account").addClass("fieldrequired");
$("#label_type_payment").addClass("fieldrequired");
$(".hide_if_no_auto_create_payment").show();';
}
}
print '});';
print '</script>'."\n";
}
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" name="formvat" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" name="formvat" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<div id="selectmethod">';
print '<div class="hideonsmartphone float">';
print $langs->trans("Type").':&nbsp;&nbsp;&nbsp;';
print '</div>';
print '<label for="radiopayment">';
print '<input type="radio" id="radiopayment" data-label="'.$langs->trans('VATPayment').'" class="flat" name="refund" value="0"'.($refund ? '' : ' checked="checked"').'>';
print '&nbsp;';
print $langs->trans("Payment");
print '</label>';
print '&nbsp;&nbsp;&nbsp;';
print '<label for="radiorefund">';
print '<input type="radio" id="radiorefund" data-label="'.$langs->trans('VATRefund').'" class="flat" name="refund" value="1"'.($refund ? ' checked="checked"' : '').'>';
print '&nbsp;';
print $langs->trans("PaymentBack");
print '</label>';
print '</div>';
print "<br>\n";
print '<div id="selectmethod">';
print '<div class="hideonsmartphone float">';
print $langs->trans("Type").':&nbsp;&nbsp;&nbsp;';
print '</div>';
print '<label for="radiopayment">';
print '<input type="radio" id="radiopayment" data-label="'.$langs->trans('VATPayment').'" class="flat" name="refund" value="0"'.($refund ? '' : ' checked="checked"').'>';
print '&nbsp;';
print $langs->trans("Payment");
print '</label>';
print '&nbsp;&nbsp;&nbsp;';
print '<label for="radiorefund">';
print '<input type="radio" id="radiorefund" data-label="'.$langs->trans('VATRefund').'" class="flat" name="refund" value="1"'.($refund ? ' checked="checked"' : '').'>';
print '&nbsp;';
print $langs->trans("Refund");
print '</label>';
print '</div>';
print "<br>\n";
print dol_get_fiche_head();
dol_fiche_head();
print '<table class="border centpercent">';
print '<table class="border centpercent">';
print "<tr>";
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1);
print '</td></tr>';
print '<tr class="hide_if_no_auto_create_payment">';
print '<td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1);
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).'</td><td>';
print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1);
print '</td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).'</td><td>';
print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1);
print '</td></tr>';
// Label
if ($refund == 1) {
@ -268,32 +460,47 @@ if ($action == 'create')
// Amount
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.GETPOST("amount", "alpha").'"></td></tr>';
if (!empty($conf->banque->enabled))
{
print '<tr><td class="fieldrequired">'.$langs->trans("BankAccount").'</td><td>';
$form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 2); // List of bank account available
print '</td></tr>';
}
// Type payment
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
// Type payment
print '<tr><td class="fieldrequired" id="label_type_payment">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(GETPOST("type_payment"), "type_payment");
print "</td>\n";
print "</tr>";
if (!empty($conf->banque->enabled))
{
print '<tr><td class="fieldrequired" id="label_fk_account">'.$langs->trans("BankAccount").'</td><td>';
$form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 1); // List of bank account available
print '</td></tr>';
}
// Auto create payment
print '<tr><td>'.$langs->trans('AutomaticCreationPayment').'</td>';
print '<td><input id="auto_create_paiement" name="auto_create_paiement" type="checkbox" '.($_REQUEST['action'] === 'add' ? (empty($auto_create_payment) ? '' : 'checked="checked"') : 'checked="checked"').' value="1"></td></tr>'."\n";
// Number
print '<tr><td>'.$langs->trans('Numero');
print '<tr class="hide_if_no_auto_create_payment"><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
// Other attributes
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Comments
print '<tr class="hide_if_no_auto_create_payment">';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';
print '<td class="tdtop"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '</table>';
// Other attributes
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print dol_get_fiche_end();
// Bouton Save payment
print '<tr class="hide_if_no_auto_create_payment"><td>';
print $langs->trans("ClosePaidVATAutomatically");
print '</td><td><input type="checkbox" checked value="1" name="closepaidtva"></td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
@ -301,7 +508,7 @@ if ($action == 'create')
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
print '</form>';
}
// View mode
@ -309,7 +516,40 @@ if ($id)
{
$head = vat_prepare_head($object);
print dol_get_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment');
$totalpaye = $object->getSommePaiement();
// Clone confirmation
if ($action === 'clone')
{
$formquestion = array(
array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
);
//$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1);
$formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240);
}
if ($action == 'paid')
{
$text = $langs->trans('ConfirmPayVAT');
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayVAT'), $text, "confirm_paid", '', '', 2);
}
if ($action == 'delete')
{
$text = $langs->trans('ConfirmDeleteVAT');
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVAT'), $text, 'confirm_delete', '', '', 2);
}
if ($action == 'edit')
{
print "<form name=\"charge\" action=\"".$_SERVER["PHP_SELF"]."?id=$object->id&amp;action=update\" method=\"post\">";
print '<input type="hidden" name="token" value="'.newToken().'">';
}
dol_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment');
$morehtmlref = '<div class="refidno">';
// Label of social contribution
@ -320,9 +560,12 @@ if ($id)
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/tva/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
@ -330,10 +573,10 @@ if ($id)
// Label
//print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
print "<tr>";
/*print "<tr>";
print '<td class="titlefield">'.$langs->trans("DatePayment").'</td><td>';
print dol_print_date($object->datep, 'day');
print '</td></tr>';
print '</td></tr>';*/
print '<tr><td>';
print $form->editfieldkey($form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")), 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day');
@ -342,22 +585,46 @@ if ($id)
//print dol_print_date($object->datev,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
if ($action == 'edit') {
print '<tr><td class="fieldrequired">' . $langs->trans("Amount") . '</td><td><input name="amount" size="10" value="' . $object->amount . '"></td></tr>';
} else {
print '<tr><td>' . $langs->trans("Amount") . '</td><td>' . price($object->amount) . '</td></tr>';
}
// Mode of payment
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode')
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'none');
}
print '</td></tr>';
// Bank account
if (!empty($conf->banque->enabled))
{
if ($object->fk_account > 0)
{
$bankline = new AccountLine($db);
$bankline->fetch($object->fk_bank);
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td>';
print $bankline->getNomUrl(1, 0, 'showall');
print '</td>';
print '</tr>';
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
// Other attributes
@ -369,22 +636,180 @@ if ($id)
print '</div>';
print dol_get_fiche_end();
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
$nbcols = 3;
if (!empty($conf->banque->enabled)) {
$nbcols++;
}
/*
* Payments
*/
$sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,";
$sql .= " c.code as type_code,c.libelle as paiement_type,";
$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal';
$sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id";
$sql .= ", ".MAIN_DB_PREFIX."tva as tva";
$sql .= " WHERE p.fk_tva = ".$id;
$sql .= " AND p.fk_tva = tva.rowid";
$sql .= " AND tva.entity IN (".getEntity('tax').")";
$sql .= " ORDER BY dp DESC";
//print $sql;
$resql = $db->query($sql);
if ($resql)
{
$totalpaye = 0;
$num = $db->num_rows($resql);
$i = 0; $total = 0;
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder paymenttable">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefPayment").'</td>';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
if (!empty($conf->banque->enabled)) {
print '<td class="liste_titre right">'.$langs->trans('BankAccount').'</td>';
}
print '<td class="right">'.$langs->trans("Amount").'</td>';
print '</tr>';
if ($num > 0)
{
$bankaccountstatic = new Account($db);
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
print '<a href="'.DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
$labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
if (!empty($conf->banque->enabled))
{
$bankaccountstatic->id = $objp->baid;
$bankaccountstatic->ref = $objp->baref;
$bankaccountstatic->label = $objp->baref;
$bankaccountstatic->number = $objp->banumber;
$bankaccountstatic->currency_code = $objp->bacurrency_code;
if (!empty($conf->accounting->enabled)) {
$bankaccountstatic->account_number = $objp->account_number;
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($objp->fk_accountancy_journal);
$bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
}
print '<td class="right">';
if ($bankaccountstatic->id)
print $bankaccountstatic->getNomUrl(1, 'transactions');
print '</td>';
}
print '<td class="right">'.price($objp->amount)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
$i++;
}
}
else {
print '<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '<td></td><td></td><td></td><td></td>';
print '</tr>';
}
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AlreadyPaid")." :</td><td class=\"right\">".price($totalpaye)."</td></tr>\n";
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AmountExpected")." :</td><td class=\"right\">".price($object->amount)."</td></tr>\n";
$resteapayer = $object->amount - $totalpaye;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("RemainderToPay")." :</td>";
print '<td class="right'.($resteapayer ? ' amountremaintopay' : (' '.$cssforamountpaymentcomplete)).'">'.price($resteapayer)."</td></tr>\n";
print "</table>";
print '</div>';
$db->free($resql);
}
else {
dol_print_error($db);
}
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
if ($action == 'edit')
{
print '<div align="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>\n";
}
/*
* Action buttons
*/
print "<div class=\"tabsAction\">\n";
if ($object->rappro == 0)
if ($action != 'edit')
{
if (!empty($user->rights->tax->charges->supprimer))
// Reopen
if ($object->paye && $user->rights->tax->charges->creer)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".dol_buildpath("/compta/tva/card.php", 1)."?id=$object->id&amp;action=reopen\">".$langs->trans("ReOpen")."</a></div>";
}
// Edit
if ($object->paye == 0 && $user->rights->tax->charges->creer)
{
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/tva/card.php?id=$object->id&amp;action=edit\">".$langs->trans("Modify")."</a></div>";
}
// Emit payment
if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer)
{
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/paiement_vat.php?id=$object->id&amp;action=create\">".$langs->trans("DoPayment")."</a></div>";
}
// Classify 'paid'
if ($object->paye == 0
&& (
(round($resteapayer) <= 0 && $object->amount > 0)
|| (round($resteapayer) >= 0 && $object->amount < 0)
)
&& $user->rights->tax->charges->creer)
{
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".DOL_URL_ROOT."/compta/tva/card.php?id=$object->id&amp;action=paid\">".$langs->trans("ClassifyPaid")."</a></div>";
}
// Clone
if ($user->rights->tax->charges->creer)
{
print "<div class=\"inline-block divButAction\"><a class=\"butAction\" href=\"".dol_buildpath("/compta/tva/card.php", 1)."?id=$object->id&amp;action=clone\">".$langs->trans("ToClone")."</a></div>";
}
if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaye))
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a></div>';
}
else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("DisabledBecausePayments"))).'">'.$langs->trans("Delete").'</a></div>';
}
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a></div>';
}
print "</div>";
}

View File

@ -0,0 +1,724 @@
<?php
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/sociales/class/paymentsocialcontribution.class.php
* \ingroup facture
* \brief File of class to manage payment of social contributions
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
/**
* Class to manage payments of social contributions
*/
class PaymentVAT extends CommonObject
{
/**
* @var string ID to identify managed object
*/
public $element = 'payment_vat';
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'payment_vat';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
public $picto = 'payment';
/**
* @var int ID
*/
public $fk_tva;
public $datec = '';
public $tms = '';
public $datep = '';
/**
* @deprecated
* @see $amount
*/
public $total;
public $amount; // Total amount of payment
public $amounts = array(); // Array of amounts
/**
* @var int ID
*/
public $fk_typepaiement;
/**
* @var string
* @deprecated
*/
public $num_paiement;
/**
* @var string
*/
public $num_payment;
/**
* @var int ID
*/
public $fk_bank;
/**
* @var int ID
*/
public $fk_user_creat;
/**
* @var int ID
*/
public $fk_user_modif;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db)
{
$this->db = $db;
}
/**
* Create payment of social contribution into database.
* Use this->amounts to have list of lines for the payment
*
* @param User $user User making payment
* @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more
* @return int <0 if KO, id of payment if OK
*/
public function create($user, $closepaidcontrib = 0)
{
global $conf, $langs;
$error = 0;
$now = dol_now();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
// Validate parametres
if (!$this->datepaye)
{
$this->error = 'ErrorBadValueForParameterCreatePaymentVAT';
return -1;
}
// Clean parameters
if (isset($this->fk_tva)) $this->fk_tva = (int) $this->fk_tva;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note)) $this->note = trim($this->note);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
$totalamount = 0;
foreach ($this->amounts as $key => $value) // How payment is dispatch
{
$newvalue = price2num($value, 'MT');
$this->amounts[$key] = $newvalue;
$totalamount += $newvalue;
}
$totalamount = price2num($totalamount);
// Check parameters
if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
$this->db->begin();
if ($totalamount != 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_vat (fk_tva, datec, datep, amount,";
$sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
$sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
$sql .= " '".$this->db->idate($this->datepaye)."',";
$sql .= " ".$totalamount.",";
$sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.",";
$sql .= " 0)";
$resql = $this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_vat");
// Insere tableau des montants / factures
foreach ($this->amounts as $key => $amount)
{
$contribid = $key;
if (is_numeric($amount) && $amount <> 0)
{
$amount = price2num($amount);
// If we want to closed payed invoices
if ($closepaidcontrib)
{
$contrib = new Tva($this->db);
$contrib->fetch($contribid);
$paiement = $contrib->getSommePaiement();
//$creditnotes=$contrib->getSumCreditNotesUsed();
$creditnotes = 0;
//$deposits=$contrib->getSumDepositsUsed();
$deposits = 0;
$alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
$remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
if ($remaintopay == 0)
{
$result = $contrib->set_paid($user);
}
else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing.");
}
}
}
}
else {
$error++;
}
}
$result = $this->call_trigger('PAYMENTVAT_CREATE', $user);
if ($result < 0) $error++;
if ($totalamount != 0 && !$error)
{
$this->amount = $totalamount;
$this->total = $totalamount; // deprecated
$this->db->commit();
return $this->id;
}
else {
$this->error = $this->db->error();
$this->db->rollback();
return -1;
}
}
/**
* Load object in memory from database
*
* @param int $id Id object
* @return int <0 if KO, >0 if OK
*/
public function fetch($id)
{
global $langs;
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.fk_tva,";
$sql .= " t.datec,";
$sql .= " t.tms,";
$sql .= " t.datep,";
$sql .= " t.amount,";
$sql .= " t.fk_typepaiement,";
$sql .= " t.num_paiement as num_payment,";
$sql .= " t.note,";
$sql .= " t.fk_bank,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_modif,";
$sql .= " pt.code as type_code, pt.libelle as type_label,";
$sql .= ' b.fk_account';
$sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
$sql .= " WHERE t.rowid = ".$id;
// TODO link on entity of tax;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->fk_tva = $obj->fk_tva;
$this->datec = $this->db->jdate($obj->datec);
$this->tms = $this->db->jdate($obj->tms);
$this->datep = $this->db->jdate($obj->datep);
$this->amount = $obj->amount;
$this->fk_typepaiement = $obj->fk_typepaiement;
$this->num_paiement = $obj->num_payment;
$this->num_payment = $obj->num_payment;
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
$this->type_code = $obj->type_code;
$this->type_label = $obj->type_label;
$this->bank_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank;
}
$this->db->free($resql);
return 1;
}
else {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
/**
* Update database
*
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function update($user = null, $notrigger = 0)
{
global $conf, $langs;
$error = 0;
// Clean parameters
if (isset($this->fk_tva)) $this->fk_tva = (int) $this->fk_tva;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note)) $this->note = trim($this->note);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET";
$sql .= " fk_tva=".(isset($this->fk_tva) ? $this->fk_tva : "null").",";
$sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
$sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
$sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
$sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").",";
$sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").",";
$sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
$sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").",";
$sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").",";
$sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null")."";
$sql .= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
// 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();
return -1 * $error;
}
else {
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
$error = 0;
dol_syslog(get_class($this)."::delete");
$this->db->begin();
if ($this->bank_line > 0)
{
$accline = new AccountLine($this->db);
$accline->fetch($this->bank_line);
$result = $accline->delete();
if ($result < 0) {
$this->errors[] = $accline->error;
$error++;
}
}
if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_vat";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
}
else {
$this->db->commit();
return 1;
}
}
/**
* Load an object from its id and create a new one in database
*
* @param User $user User making the clone
* @param int $fromid Id of object to clone
* @return int New id of clone
*/
public function createFromClone(User $user, $fromid)
{
$error = 0;
$object = new PaymentSocialContribution($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
$object->id = 0;
$object->statut = 0;
// Clear fields
// ...
// Create clone
$object->context['createfromclone'] = 'createfromclone';
$result = $object->create($user);
// Other options
if ($result < 0)
{
$this->error = $object->error;
$error++;
}
unset($object->context['createfromclone']);
// End
if (!$error)
{
$this->db->commit();
return $object->id;
}
else {
$this->db->rollback();
return -1;
}
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
public function initAsSpecimen()
{
$this->id = 0;
$this->fk_tva = '';
$this->datec = '';
$this->tms = '';
$this->datep = '';
$this->amount = '';
$this->fk_typepaiement = '';
$this->num_payment = '';
$this->note_private = '';
$this->note_public = '';
$this->fk_bank = '';
$this->fk_user_creat = '';
$this->fk_user_modif = '';
}
/**
* Add record into bank for payment with links between this bank record and invoices of payment.
* All payment properties must have been set first like after a call to create().
*
* @param User $user Object of user making payment
* @param string $mode 'payment_sc'
* @param string $label Label to use in bank record
* @param int $accountid Id of bank account to do link with
* @param string $emetteur_nom Name of transmitter
* @param string $emetteur_banque Name of bank
* @return int <0 if KO, >0 if OK
*/
public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
{
global $conf;
// Clean data
$this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
$error = 0;
if (!empty($conf->banque->enabled))
{
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$acc->fetch($accountid);
$total = $this->total;
if ($mode == 'payment_vat') $total = -$total;
// Insert payment into llx_bank
$bank_line_id = $acc->addline(
$this->datepaye,
$this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
$label,
$total,
$this->num_payment,
'',
$user,
$emetteur_nom,
$emetteur_banque
);
// Mise a jour fk_bank dans llx_paiement.
// On connait ainsi le paiement qui a genere l'ecriture bancaire
if ($bank_line_id > 0)
{
$result = $this->update_fk_bank($bank_line_id);
if ($result <= 0)
{
$error++;
dol_print_error($this->db);
}
// Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
$url = '';
if ($mode == 'payment_vat') $url = DOL_URL_ROOT.'/compta/payment_vat/card.php?id=';
if ($url)
{
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
if ($result <= 0)
{
$error++;
dol_print_error($this->db);
}
}
// Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
$linkaddedforthirdparty = array();
foreach ($this->amounts as $key => $value)
{
if ($mode == 'payment_vat')
{
$tva = new Tva($this->db);
$tva->fetch($key);
$result = $acc->add_url_line($bank_line_id, $tva->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', '('.$tva->label.')', 'vat');
if ($result <= 0) dol_print_error($this->db);
}
}
}
else {
$this->error = $acc->error;
$error++;
}
}
if (!$error)
{
return 1;
}
else {
return -1;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Mise a jour du lien entre le paiement de tva et la ligne dans llx_bank generee
*
* @param int $id_bank Id if bank
* @return int >0 if OK, <=0 if KO
*/
public function update_fk_bank($id_bank)
{
// phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
return 1;
}
else {
$this->error = $this->db->error();
return 0;
}
}
/**
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
*/
public function getLibStatut($mode = 0)
{
return $this->LibStatut($this->statut, $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
* @param int $status Statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
/*if ($mode == 0)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
if ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
if ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
if ($mode == 6)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}*/
return '';
}
/**
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $maxlen Longueur max libelle
* @return string Chaine avec URL
*/
public function getNomUrl($withpicto = 0, $maxlen = 0)
{
global $langs;
$result = '';
if (empty($this->ref)) $this->ref = $this->lib;
$label = img_picto('', $this->picto).' <u>'.$langs->trans("VATPayment").'</u>';
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (!empty($this->label)) {
$labeltoshow = $this->label;
$reg = array();
if (preg_match('/^\((.*)\)$/i', $this->label, $reg))
{
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1] == 'paiement') $reg[1] = 'Payment';
$labeltoshow = $langs->trans($reg[1]);
}
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
}
if ($this->datep) $label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'day');
if (!empty($this->id)) {
$link = '<a href="'.DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend = '</a>';
if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
if ($withpicto && $withpicto != 2) $result .= ' ';
if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
}
return $result;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -35,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
// Load translation files required by the page
$langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin"));
$form = new Form($db);
$now = dol_now();
$current_date = dol_getdate($now);
if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1;
@ -57,11 +59,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$q = GETPOST("q", "int");
if (empty($q))
{
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else {
if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); }
else {
if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter
$date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm');
$date_end = dol_time_plus_duree($date_start, 3, 'm') - 1;
} elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat
}
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat
if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) {
if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year
$year_start--;
@ -73,12 +77,14 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
}
$date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false);
$date_end = dol_time_plus_duree($date_start, 1, 'y') - 1;
} elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month
}
elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month
$date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm');
$date_end = dol_time_plus_duree($date_start, 1, 'm') - 1;
}
}
} else {
}
else {
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
@ -108,100 +114,102 @@ $result = restrictedArea($user, 'tax', '', '', 'charges');
*/
function pt($db, $sql, $date)
{
global $conf, $bc, $langs;
global $conf, $bc, $langs, $form;
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
$total = 0;
print '<table class="noborder centpercent">';
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
$total = 0;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="nowrap">'.$date.'</td>';
print '<td class="right">'.$langs->trans("ClaimedForThisPeriod").'</td>';
print '<td class="right">'.$langs->trans("PaidDuringThisPeriod").'</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="nowrap">'.$date.'</td>';
print '<td class="right">'.$langs->trans("ClaimedForThisPeriod").'</td>';
print '<td class="right">'.$langs->trans("PaidDuringThisPeriod").$form->textwithpicto('', $langs->trans('PaidDuringThisPeriodDesc'), 1).'</td>';
print "</tr>\n";
$totalclaimed = 0;
$totalpaid = 0;
$amountclaimed = 0;
$amountpaid = 0;
$previousmonth = '';
$previousmode = '';
$mode = '';
$totalclaimed = 0;
$totalpaid = 0;
$amountclaimed = 0;
$amountpaid = 0;
$previousmonth = '';
$previousmode = '';
$mode = '';
while ($i < $num) {
$obj = $db->fetch_object($result);
$mode = $obj->mode;
while ($i < $num) {
$obj = $db->fetch_object($result);
$mode = $obj->mode;
//print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
if ($obj->mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
//print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode;
if ($obj->mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
$amountclaimed = 0;
$amountpaid = 0;
}
$amountclaimed = 0;
$amountpaid = 0;
}
if ($obj->mode == 'claimed')
{
$amountclaimed = $obj->mm;
$totalclaimed = $totalclaimed + $amountclaimed;
}
if ($obj->mode == 'paid')
{
$amountpaid = $obj->mm;
$totalpaid = $totalpaid + $amountpaid;
}
if ($obj->mode == 'claimed')
{
$amountclaimed = $obj->mm;
$totalclaimed = $totalclaimed + $amountclaimed;
}
if ($obj->mode == 'paid')
{
$amountpaid = $obj->mm;
$totalpaid = $totalpaid + $amountpaid;
}
if ($obj->mode == 'paid')
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$obj->dm."</td>\n";
print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
$amountclaimed = 0;
$amountpaid = 0;
$previousmode = '';
$previousmonth = '';
} else {
$previousmode = $obj->mode;
$previousmonth = $obj->dm;
}
if ($obj->mode == 'paid')
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$obj->dm."</td>\n";
print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
$amountclaimed = 0;
$amountpaid = 0;
$previousmode = '';
$previousmonth = '';
}
else {
$previousmode = $obj->mode;
$previousmonth = $obj->dm;
}
$i++;
}
$i++;
}
if ($mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
if ($mode == 'claimed' && !empty($previousmode))
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$previousmonth."</td>\n";
print '<td class="nowrap right">'.price($amountclaimed)."</td>\n";
print '<td class="nowrap right">'.price($amountpaid)."</td>\n";
print "</tr>\n";
$amountclaimed = 0;
$amountpaid = 0;
}
$amountclaimed = 0;
$amountpaid = 0;
}
print '<tr class="liste_total">';
print '<td class="right">'.$langs->trans("Total").'</td>';
print '<td class="nowrap right">'.price($totalclaimed).'</td>';
print '<td class="nowrap right">'.price($totalpaid).'</td>';
print "</tr>";
print '<tr class="liste_total">';
print '<td class="right">'.$langs->trans("Total").'</td>';
print '<td class="nowrap right">'.price($totalclaimed).'</td>';
print '<td class="nowrap right">'.price($totalpaid).'</td>';
print "</tr>";
print "</table>";
print "</table>";
$db->free($result);
} else {
dol_print_error($db);
}
$db->free($result);
}
else {
dol_print_error($db);
}
}
@ -209,7 +217,6 @@ function pt($db, $sql, $date)
* View
*/
$form = new Form($db);
$company_static = new Societe($db);
$tva = new Tva($db);
@ -362,7 +369,8 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
//'link' =>$expensereport->getNomUrl(1)
);
} else {
}
else {
//$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id];
//$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id];
//$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id];
@ -392,144 +400,144 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc
}
//now we have an array (x_both) indexed by rates for coll and paye
$action = "tva";
$object = array(&$x_coll, &$x_paye, &$x_both);
$parameters["mode"] = $modetax;
$parameters["year"] = $y;
$parameters["month"] = $m;
$parameters["type"] = 'vat';
$action = "tva";
$object = array(&$x_coll, &$x_paye, &$x_both);
$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
// 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
if (!is_array($x_coll) && $coll_listbuy == -1)
{
$langs->load("errors");
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
break;
}
if (!is_array($x_paye) && $coll_listbuy == -2)
{
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
break;
}
if (!is_array($x_coll) && $coll_listbuy == -1)
{
$langs->load("errors");
print '<tr><td colspan="5">'.$langs->trans("ErrorNoAccountancyModuleLoaded").'</td></tr>';
break;
}
if (!is_array($x_paye) && $coll_listbuy == -2)
{
print '<tr><td colspan="5">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
break;
}
print '<tr class="oddeven">';
print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/compta/tva/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>';
print '<tr class="oddeven">';
print '<td class="nowrap"><a href="'.DOL_URL_ROOT.'/compta/tva/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>';
$x_coll_sum = 0;
foreach (array_keys($x_coll) as $rate)
{
$subtot_coll_total_ht = 0;
$subtot_coll_vat = 0;
$x_coll_sum = 0;
foreach (array_keys($x_coll) as $rate)
{
$subtot_coll_total_ht = 0;
$subtot_coll_vat = 0;
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type = 1;
}
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type = 1;
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
{
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
$subtot_coll_total_ht += $temp_ht;
$subtot_coll_vat += $temp_vat;
$x_coll_sum += $temp_vat;
}
}
print '<td class="nowrap right">'.price(price2num($x_coll_sum, 'MT')).'</td>';
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
{
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
$subtot_coll_total_ht += $temp_ht;
$subtot_coll_vat += $temp_vat;
$x_coll_sum += $temp_vat;
}
}
print '<td class="nowrap right">'.price(price2num($x_coll_sum, 'MT')).'</td>';
$x_paye_sum = 0;
foreach (array_keys($x_paye) as $rate)
{
$subtot_paye_total_ht = 0;
$subtot_paye_vat = 0;
$x_paye_sum = 0;
foreach (array_keys($x_paye) as $rate)
{
$subtot_paye_total_ht = 0;
$subtot_paye_vat = 0;
foreach ($x_both[$rate]['paye']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type = 1;
}
foreach ($x_both[$rate]['paye']['detail'] as $index => $fields)
{
// Payment
$ratiopaymentinvoice = 1;
if ($modetax != 1)
{
// Define type
// We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type = (isset($fields['dtype']) ? $fields['dtype'] : $fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type
// was not saved.
if (!empty($fields['ddate_start'])) {
$type = 1;
}
if (!empty($fields['ddate_end'])) {
$type = 1;
}
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
{
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
$subtot_paye_total_ht += $temp_ht;
$subtot_paye_vat += $temp_vat;
$x_paye_sum += $temp_vat;
}
}
print '<td class="nowrap right">'.price(price2num($x_paye_sum, 'MT')).'</td>';
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice'))
{
//print $langs->trans("NA");
} else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
}
}
}
//var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice);
$temp_ht = $fields['totalht'] * $ratiopaymentinvoice;
$temp_vat = $fields['vat'] * $ratiopaymentinvoice;
$subtot_paye_total_ht += $temp_ht;
$subtot_paye_vat += $temp_vat;
$x_paye_sum += $temp_vat;
}
}
print '<td class="nowrap right">'.price(price2num($x_paye_sum, 'MT')).'</td>';
$subtotalcoll = $subtotalcoll + $x_coll_sum;
$subtotalpaye = $subtotalpaye + $x_paye_sum;
$subtotalcoll = $subtotalcoll + $x_coll_sum;
$subtotalpaye = $subtotalpaye + $x_paye_sum;
$diff = $x_coll_sum - $x_paye_sum;
$total = $total + $diff;
$subtotal = price2num($subtotal + $diff, 'MT');
$diff = $x_coll_sum - $x_paye_sum;
$total = $total + $diff;
$subtotal = price2num($subtotal + $diff, 'MT');
print '<td class="nowrap right">'.price(price2num($diff, 'MT')).'</td>'."\n";
print "<td>&nbsp;</td>\n";
print "</tr>\n";
print '<td class="nowrap right">'.price(price2num($diff, 'MT')).'</td>'."\n";
print "<td>&nbsp;</td>\n";
print "</tr>\n";
$i++; $m++;
if ($i > 2)
{
print '<tr class="liste_total">';
print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m / 3).'&year='.$y.'">'.$langs->trans("SubTotal").'</a>:</td>';
print '<td class="nowrap right">'.price(price2num($subtotalcoll, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotalpaye, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotal, 'MT')).'</td>';
print '<td>&nbsp;</td></tr>';
$i = 0;
$subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0;
}
$i++; $m++;
if ($i > 2)
{
print '<tr class="liste_total">';
print '<td class="right"><a href="quadri_detail.php?leftmenu=tax_vat&q='.round($m / 3).'&year='.$y.'">'.$langs->trans("SubTotal").'</a>:</td>';
print '<td class="nowrap right">'.price(price2num($subtotalcoll, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotalpaye, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($subtotal, 'MT')).'</td>';
print '<td>&nbsp;</td></tr>';
$i = 0;
$subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0;
}
}
print '<tr class="liste_total"><td class="right" colspan="3">'.$langs->trans("TotalToPay").':</td><td class="nowrap right">'.price(price2num($total, 'MT')).'</td>';
print "<td>&nbsp;</td>\n";
@ -550,18 +558,19 @@ print load_fiche_titre($langs->trans("VATPaid"), '', '');
$sql = '';
$sql .= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')";
$sql .= "SELECT SUM(amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'claimed' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as tva";
$sql .= " WHERE tva.entity = ".$conf->entity;
$sql .= " AND (tva.datev >= '".$db->idate($date_start)."' AND tva.datev <= '".$db->idate($date_end)."')";
$sql .= " GROUP BY dm";
$sql .= " UNION ";
$sql .= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql .= " WHERE f.entity = ".$conf->entity;
$sql .= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')";
$sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as tva";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON (tva.rowid = ptva.fk_tva)";
$sql .= " WHERE tva.entity = ".$conf->entity;
$sql .= " AND (tva.datev >= '".$db->idate($date_start)."' AND tva.datev <= '".$db->idate($date_end)."')";
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm ASC, mode ASC";
@ -578,37 +587,37 @@ if (!empty($conf->global->MAIN_FEATURES_LEVEL))
* Recap
*/
print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation
print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation
$sql1 = "SELECT SUM(amount) as mm";
$sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql1 .= " WHERE f.entity = ".$conf->entity;
$sql1 .= " AND f.datev >= '".$db->idate($date_start)."'";
$sql1 .= " AND f.datev <= '".$db->idate($date_end)."'";
$sql1 = "SELECT SUM(amount) as mm";
$sql1 .= " FROM ".MAIN_DB_PREFIX."tva as f";
$sql1 .= " WHERE f.entity = ".$conf->entity;
$sql1 .= " AND f.datev >= '".$db->idate($date_start)."'";
$sql1 .= " AND f.datev <= '".$db->idate($date_end)."'";
$result = $db->query($sql1);
if ($result) {
$obj = $db->fetch_object($result);
print '<table class="noborder centpercent">';
$result = $db->query($sql1);
if ($result) {
$obj = $db->fetch_object($result);
print '<table class="noborder centpercent">';
print "<tr>";
print '<td class="right">'.$langs->trans("VATDue").'</td>';
print '<td class="nowrap right">'.price(price2num($total, 'MT')).'</td>';
print "</tr>\n";
print "<tr>";
print '<td class="right">'.$langs->trans("VATDue").'</td>';
print '<td class="nowrap right">'.price(price2num($total, 'MT')).'</td>';
print "</tr>\n";
print "<tr>";
print '<td class="right">'.$langs->trans("VATPaid").'</td>';
print '<td class="nowrap right">'.price(price2num($obj->mm, 'MT'))."</td>\n";
print "</tr>\n";
print "<tr>";
print '<td class="right">'.$langs->trans("VATPaid").'</td>';
print '<td class="nowrap right">'.price(price2num($obj->mm, 'MT'))."</td>\n";
print "</tr>\n";
$restopay = $total - $obj->mm;
print "<tr>";
print '<td class="right">'.$langs->trans("RemainToPay").'</td>';
print '<td class="nowrap right">'.price(price2num($restopay, 'MT')).'</td>';
print "</tr>\n";
$restopay = $total - $obj->mm;
print "<tr>";
print '<td class="right">'.$langs->trans("RemainToPay").'</td>';
print '<td class="nowrap right">'.price(price2num($restopay, 'MT')).'</td>';
print "</tr>\n";
print '</table>';
}
print '</table>';
}
}
print '</div></div>';

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -57,6 +58,7 @@ $search_type = GETPOST('search_type', 'int');
$search_cheque = GETPOST('search_cheque', 'alpha');
$search_account = GETPOST('search_account', 'int');
$search_amount = GETPOST('search_amount', 'alpha');
$search_status = GETPOST('search_status', 'int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
@ -75,12 +77,9 @@ $arrayfields = array(
't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",),
't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"),
't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"),
't.datep' =>array('checked'=>1, 'position'=>40, 'label'=>"DatePayment"),
't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"Type"),
't.num_payment' =>array('checked'=>1, 'position'=>60, 'label'=>"Numero", 'tooltip'=>"ChequeOrTransferNumber"),
'transaction' =>array('checked'=>1, 'position'=>70, 'label'=>"BankTransactionLine", 'enabled'=>(!empty($conf->banque->enabled))),
'ba.label' =>array('checked'=>1, 'position'=>80, 'label'=>"Account", 'enable'=>(!empty($conf->banque->enabled))),
't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"PayedByThisPayment"),
't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"Amount"),
't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
@ -113,6 +112,7 @@ if (empty($reshook)) {
$search_cheque = '';
$search_account = '';
$search_amount = '';
$search_status = '';
}
}
@ -128,15 +128,13 @@ $bankstatic = new Account($db);
$accountingjournal = new AccountingJournal($db);
$bankline = new AccountLine($db);
llxHeader('', $langs->trans("VATPayments"));
llxHeader('', $langs->trans("VATDeclarations"));
$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank';
$sql .= ', ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel';
$sql .= ', pst.code as payment_code';
$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.num_payment, pst.code as payment_code,';
$sql .= ' SUM(ptva.amount) as alreadypayed';
$sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON t.fk_typepayment = pst.id';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON ptva.fk_tva = t.rowid";
$sql .= ' WHERE t.entity IN ('.getEntity($object->element).')';
if (!empty($search_ref)) $sql .= natural_search('t.rowid', $search_ref);
@ -146,10 +144,11 @@ if (!empty($search_dateend_end)) $sql .= ' AND t.datev <= "'.$db->idate($sea
if (!empty($search_datepayment_start)) $sql .= ' AND t.datep >= "'.$db->idate($search_datepayment_start).'"';
if (!empty($search_datepayment_end)) $sql .= ' AND t.datep <= "'.$db->idate($search_datepayment_end).'"';
if (!empty($search_type) && $search_type > 0) $sql .= ' AND t.fk_typepayment='.$search_type;
if (!empty($search_cheque)) $sql .= natural_search('t.num_payment', $search_cheque);
if (!empty($search_account) && $search_account > 0) $sql .= ' AND b.fk_account='.$search_account;
if (!empty($search_amount)) $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1);
if ($search_status != '' && $search_status >= 0) $sql .= " AND t.paye = ".$db->escape($search_status);
$sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.num_payment, pst.code";
$sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = '';
@ -200,6 +199,7 @@ if (!empty($search_type) && $search_type > 0) $param .= '&search_type='.$search
if (!empty($search_cheque)) $param .= '&search_cheque="'.$search_cheque.'"';
if (!empty($search_account) && $search_account > 0) $param .= '&search_account='.$search_account;
if (!empty($search_amount)) $param .= '&search_amount="'.$search_amount.'"';
if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -213,7 +213,7 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid;
$newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
print_barre_liste($langs->trans("VATPayments"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
@ -257,7 +257,7 @@ if (!empty($arrayfields['t.datev']['checked'])) {
}
// Filter: Date payment
if (!empty($arrayfields['t.datep']['checked'])) {
/*if (!empty($arrayfields['t.datep']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
@ -266,7 +266,7 @@ if (!empty($arrayfields['t.datep']['checked'])) {
print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
}*/
// Filter: Type
if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
@ -275,26 +275,6 @@ if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
print '</td>';
}
// Filter: Cheque number
if (!empty($arrayfields['t.num_payment']['checked'])) {
print '<td class="liste_titre left">';
print '<input name="search_cheque" class="flat" type="text" size="8" value="'.$search_cheque.'">';
print '</td>';
}
// Filter: Bank transaction number (placeholder)
if (!empty($arrayfields['transaction']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Filter: Bank account
if (!empty($arrayfields['ba.label']['checked'])) {
print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1);
print '</td>';
}
// Filter: Amount
if (!empty($arrayfields['t.amount']['checked'])) {
print '<td class="liste_titre right">';
@ -302,6 +282,14 @@ if (!empty($arrayfields['t.amount']['checked'])) {
print '</td>';
}
// Status
if (!empty($arrayfields['t.status']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone right">';
$liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
print $form->selectarray('search_status', $liststatus, $search_status, 1);
print '</td>';
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields);
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
@ -319,12 +307,9 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titr
if (!empty($arrayfields['t.rowid']['checked'])) print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder);
if (!empty($arrayfields['t.datev']['checked'])) print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['t.datep']['checked'])) print_liste_field_titre($arrayfields['t.datep']['label'], $_SERVER['PHP_SELF'], 't.datep', '', $param, 'align="center"', $sortfield, $sortorder);
if (!empty($arrayfields['t.fk_typepayment']['checked'])) print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left ');
if (!empty($arrayfields['t.num_payment']['checked'])) print_liste_field_titre($arrayfields['t.num_payment']['label'], $_SERVER['PHP_SELF'], 't.num_payment', '', $param, '', $sortfield, $sortorder, '', $arrayfields['t.num_payment']['tooltip']);
if (!empty($arrayfields['transaction']['checked'])) print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['ba.label']['checked'])) print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER['PHP_SELF'], 'ba.label', '', $param, '', $sortfield, $sortorder, 'left ');
if (!empty($arrayfields['t.amount']['checked'])) print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['t.status']['checked'])) print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder);
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
@ -341,6 +326,7 @@ while ($i < min($num, $limit)) {
$tva_static->id = $obj->rowid;
$tva_static->ref = $obj->rowid;
$tva_static->label = $obj->label;
print '<tr class="oddeven">';
@ -369,10 +355,10 @@ while ($i < min($num, $limit)) {
}
// Date payment
if (!empty($arrayfields['t.datep']['checked'])) {
/*if (!empty($arrayfields['t.datep']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
if (!$i) $totalarray['nbfield']++;
}
}*/
// Type
if (!empty($arrayfields['t.fk_typepayment']['checked']))
@ -381,21 +367,8 @@ while ($i < min($num, $limit)) {
if (!$i) $totalarray['nbfield']++;
}
// Cheque number
if (!empty($arrayfields['t.num_payment']['checked'])) {
print '<td>'.$obj->num_payment.'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Bank transaction
if (!empty($arrayfields['transaction']['checked'])) {
$bankline->fetch($obj->fk_bank);
print '<td>'.$bankline->getNomUrl(1, 0).'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Account
if (!empty($arrayfields['ba.label']['checked'])) {
/*if (!empty($arrayfields['ba.label']['checked'])) {
print '<td>';
if ($obj->fk_bank > 0) {
$bankstatic->id = $obj->bid;
@ -411,14 +384,22 @@ while ($i < min($num, $limit)) {
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
}*/
// Amount
$total = $total + $obj->amount;
print '<td class="nowrap right">'.price($obj->amount).'</td>';
if (!$i) $totalarray['nbfield']++;
$totalarray['pos'][$totalarray['nbfield']] = 'amount';
$totalarray['val']['amount'] += $objp->amount;
if (!empty($arrayfields['t.amount']['checked'])) {
$total = $total + $obj->amount;
print '<td class="nowrap right">' . price($obj->amount) . '</td>';
if (!$i) $totalarray['nbfield']++;
$totalarray['pos'][$totalarray['nbfield']] = 'amount';
$totalarray['val']['amount'] += $obj->amount;
}
if (!empty($arrayfields['t.status']['checked'])) {
print '<td class="nowrap right">' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '</td>';
if (!$i) $totalarray['nbfield']++;
if (!empty($arrayfields['t.amount']['checked'])) $totalarray['pos'][$totalarray['nbfield']] = '';
}
// Buttons
print '<td></td>';

View File

@ -0,0 +1,217 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/tva/payments.php
* \ingroup compta
* \brief Page to list payments of special expenses
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('compta', 'bills'));
// Security check
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|');
$mode = GETPOST("mode", 'alpha');
$year = GETPOST("year", 'int');
$filtre = GETPOST("filtre", 'alpha');
if (!$year && $mode != 'tvaonly') { $year = date("Y", time()); }
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : 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 (!$sortfield) $sortfield = "ptva.datep";
if (!$sortorder) $sortorder = "DESC";
/*
* View
*/
$tva_static = new Tva($db);
$tva = new Tva($db);
$payment_vat_static = new PaymentVAT($db);
$sal_static = new PaymentSalary($db);
llxHeader('', $langs->trans("VATExpensesArea"));
$title = $langs->trans("VATPayments");
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
if ($sortfield) $param .= '&sortfield='.$sortfield;
if ($sortorder) $param .= '&sortorder='.$sortorder;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" 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="mode" value="'.$mode.'">';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit);
if ($year) $param .= '&year='.$year;
if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire)
{
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "ptva.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("LabelContrib", $_SERVER["PHP_SELF"], "tva.label", "", $param, '', $sortfield, $sortorder);
//print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "tva.fk_type", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "tva.datev", "", $param, 'width="140px"', $sortfield, $sortorder);
print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "tva.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ptva.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print "</tr>\n";
$sql = "SELECT tva.rowid, tva.label as label, b.fk_account";
$sql .= ", tva.datev";
$sql .= ", tva.amount as total,";
$sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaye, ptva.num_paiement as num_payment,";
$sql .= " pct.code as payment_code";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as tva,";
$sql .= " ".MAIN_DB_PREFIX."payment_vat as ptva";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON (b.rowid = ptva.fk_bank)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank_account as bank ON (bank.rowid = b.fk_account)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id";
$sql .= " WHERE ptva.fk_tva = tva.rowid";
$sql .= " AND tva.entity = ".$conf->entity;
if ($year > 0)
{
$sql .= " AND (";
// Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance,
// ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire
$sql .= " (tva.datev IS NOT NULL AND tva.datev between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= " OR (tva.datev IS NULL AND tva.datev between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')";
$sql .= ")";
}
if (preg_match('/^cs\./', $sortfield)
|| preg_match('/^tva\./', $sortfield)
|| preg_match('/^ptva\./', $sortfield)
|| preg_match('/^pct\./', $sortfield)
|| preg_match('/^bank\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder);
//$sql.= $db->plimit($limit+1,$offset);
//print $sql;
dol_syslog("compta/tva/payments.php: select payment", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
$totalnb = 0;
$totalpaye = 0;
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
$payment_vat_static->id = $obj->pid;
$payment_vat_static->ref = $obj->pid;
print '<tr class="oddeven">';
// Ref payment
print '<td>'.$payment_vat_static->getNomUrl(1)."</td>\n";
// Date payment
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
// Type payment
print '<td>';
if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' ';
print $obj->num_payment.'</td>';
// Account
print '<td>';
$account = new Account($db);
$account->fetch($obj->fk_account);
print $account->getNomUrl(1);
print '</td>';
// Label
print '<td>';
$tva->id = $obj->rowid;
$tva->ref = $obj->rowid;
$tva->label = $obj->label;
print $tva->getNomUrl(1, '20');
print '</td>';
// Type
//print '<td><a href="../tva/list.php?filtre=tva.fk_type:'.$obj->type.'">'.$obj->type_label.'</a></td>';
// Date
$date = $obj->datev;
print '<td>'.dol_print_date($date, 'day').'</td>';
// Expected to pay
print '<td class="right">'.price($obj->total).'</td>';
// Paid
print '<td class="right">';
if ($obj->totalpaye) print price($obj->totalpaye);
print '</td>';
print '</tr>';
$total = $total + $obj->total;
$totalnb = $totalnb + $obj->nb;
$totalpaye = $totalpaye + $obj->totalpaye;
$i++;
}
print '<tr class="liste_total"><td colspan="3" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total right"></td>'; // A total here has no sense
//print '<td align="center" class="liste_total">&nbsp;</td>';
print '<td align="center" class="liste_total">&nbsp;</td>';
print '<td align="center" class="liste_total">&nbsp;</td>';
print '<td align="center" class="liste_total">&nbsp;</td>';
print '<td class="liste_total right">'.price($totalpaye)."</td>";
print "</tr>";
}
else {
dol_print_error($db);
}
print '</table>';
print '</div>';
}
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@ -175,6 +175,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$sall = "";
$search_status = "";
$toselect = '';
$search_type_thirdparty = '';
$search_array_options = array();
}
@ -198,6 +199,7 @@ $form = new Form($db);
$formfile = new FormFile($db);
$formother = new FormOther($db);
$socstatic = new Societe($db);
$formcompany = new FormCompany($db);
$contracttmp = new Contrat($db);
$sql = 'SELECT';
@ -235,6 +237,7 @@ if ($search_user > 0)
}
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= ' AND c.entity IN ('.getEntity('contract').')';
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category;
if ($socid) $sql .= " AND s.rowid = ".$db->escape($socid);
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
@ -346,6 +349,7 @@ if ($search_dfyear != '') $param .= '&search_dfyear='.urlencode($search_df
if ($search_dfmonth != '') $param .= '&search_dfmonth='.urlencode($search_dfmonth);
if ($search_sale != '') $param .= '&search_sale='.urlencode($search_sale);
if ($search_user != '') $param .= '&search_user='.urlencode($search_user);
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category);
if ($show_files) $param .= '&show_files='.urlencode($show_files);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
@ -491,7 +495,7 @@ if (!empty($arrayfields['country.code_iso']['checked']))
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
if (!empty($arrayfields['sale_representative']['checked']))

View File

@ -292,6 +292,7 @@ class box_dolibarr_state_board extends ModeleBoxes
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
$this->info_box_contents[0][0] = array(
'tr' => 'class="nohover"',
'td' => '',
'textnoformat' => $boxstat
);

View File

@ -96,6 +96,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$listofopplabel = array();
$listofoppcode = array();
$colorseriesstat = array();
$bordercolorseries = array();
$sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls";
$sql .= " WHERE active=1";
@ -113,19 +114,24 @@ class box_funnel_of_prospection extends ModeleBoxes
$listofoppcode[$objp->rowid] = $objp->code;
switch ($objp->code) {
case 'PROSP':
$colorseriesstat[$objp->rowid] = "-" . $badgeStatus0;
$colorseriesstat[$objp->rowid] = '#FFFFFF';
$bordercolorseries[$objp->rowid] = $badgeStatus0;
break;
case 'QUAL':
$colorseriesstat[$objp->rowid] = "-" . $badgeStatus1;
$colorseriesstat[$objp->rowid] = '#FFFFFF';
$bordercolorseries[$objp->rowid] = $badgeStatus1;
break;
case 'PROPO':
$colorseriesstat[$objp->rowid] = $badgeStatus1;
$bordercolorseries[$objp->rowid] = $badgeStatus1;
break;
case 'NEGO':
$colorseriesstat[$objp->rowid] = $badgeStatus4;
$bordercolorseries[$objp->rowid] = $badgeStatus4;
break;
case 'WON':
$colorseriesstat[$objp->rowid] = $badgeStatus6;
$bordercolorseries[$objp->rowid] = $badgeStatus6;
break;
default:
break;
@ -191,7 +197,10 @@ class box_funnel_of_prospection extends ModeleBoxes
$listofstatus = array_keys($listofoppstatus);
$liststatus = array();
$data = array('');
$customlabels = array();
$total=0;
foreach ($listofstatus as $status) {
$customlabel = '';
$labelStatus = '';
if ($status != 7) {
$code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code');
@ -201,8 +210,9 @@ class box_funnel_of_prospection extends ModeleBoxes
if (empty($labelStatus)) {
$labelStatus = $listofopplabel[$status];
}
$data[] = (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0);
$amount = (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0);
$data[] = $amount;
$customlabel = $amount;
$liststatus[] = $labelStatus;
if (!$conf->use_javascript_ajax) {
$stringtoprint .= '<tr class="oddeven">';
@ -211,6 +221,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$stringtoprint .= "</tr>\n";
}
}
$customlabels[]=$customlabel;
}
$dataseries[] = $data;
if ($conf->use_javascript_ajax) {
@ -219,13 +230,18 @@ class box_funnel_of_prospection extends ModeleBoxes
$dolgraph->SetMinValue(0);
$dolgraph->SetData($dataseries);
$dolgraph->SetLegend($liststatus);
$dolgraph->setHideXValues(true);
$dolgraph->SetDataColor(array_values($colorseriesstat));
$dolgraph->setBorderColor(array_values($bordercolorseries));
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->setTitle('');
$dolgraph->setMirrorGraphValues(true);
$dolgraph->setBorderWidth(2);
$dolgraph->SetType(array('horizontalbars'));
$dolgraph->SetHeight('200');
$dolgraph->SetWidth('600');
$dolgraph->setTooltipsTitles($liststatus);
$dolgraph->setTooltipsLabels($customlabels);
$dolgraph->mode = 'depth';
$dolgraph->draw('idgraphleadfunnel');
$stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1);

View File

@ -2078,6 +2078,7 @@ abstract class CommonObject
$fieldname = 'fk_mode_reglement';
if ($this->element == 'societe') $fieldname = 'mode_reglement';
if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier';
if (get_class($this) == 'Tva') $fieldname = 'fk_typepayment';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');

View File

@ -66,6 +66,7 @@ class DolGraph
public $labelInterval = -1;
public $hideXGrid = false;
public $hideXValues = false;
public $hideYGrid = false;
public $Legend = array();
@ -75,6 +76,12 @@ class DolGraph
public $showpercent = 0;
public $combine = 0; // 0.05 if you want to combine records < 5% into "other"
public $graph; // Objet Graph (Artichow, Phplot...)
/**
* @var boolean Mirrors graph values
*/
public $mirrorGraphValues = false;
public $tooltipsTitles = null;
public $tooltipsLabels = null;
/**
* @var string Error code (or message)
@ -85,6 +92,7 @@ class DolGraph
public $bgcolor; // array(R,G,B)
public $bgcolorgrid = array(255, 255, 255); // array(R,G,B)
public $datacolor; // array(array(R,G,B),...)
public $borderwidth = 1;
private $stringtoshow; // To store string to output graph into HTML page
@ -175,6 +183,18 @@ class DolGraph
return true;
}
/**
* Hide X Values
*
* @param boolean $bool XValues or not
* @return boolean true
*/
public function setHideXValues($bool)
{
$this->hideXValues = $bool;
return true;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Hide Y grid
@ -244,9 +264,9 @@ class DolGraph
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set data
* Set data color
*
* @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...)
* @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...) or array('#......','#......'...)
* @return void
*/
public function SetDataColor($datacolor)
@ -255,6 +275,50 @@ class DolGraph
$this->datacolor = $datacolor;
}
/**
* Set border color
*
* @param array $bordercolor Border Color array(array(R,G,B),array(R,G,B)...) or array('#FFFFFF','#......'...)
* @return void
*/
public function setBorderColor($bordercolor)
{
$this->bordercolor = $bordercolor;
}
/**
* Set border width
*
* @param int $borderwidth Border Width
* @return void
*/
public function setBorderWidth($borderwidth)
{
$this->borderwidth = $borderwidth;
}
/**
* Set tooltips labels of the graph
*
* @param array $tooltipsLabels Tooltips Labels array('...','...'...)
* @return void
*/
public function setTooltipsLabels($tooltipsLabels)
{
$this->tooltipsLabels = $tooltipsLabels;
}
/**
* Set tooltips titles of the graph
*
* @param array $tooltipsTitles Tooltips Titles array('...','...'...)
* @return void
*/
public function setTooltipsTitles($tooltipsTitles)
{
$this->tooltipsTitles = $tooltipsTitles;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set type
@ -408,6 +472,17 @@ class DolGraph
unset($this->bgcolorgrid);
}
/**
* Mirror Values of the graph
*
* @param boolean $mirrorGraphValues Mirror Values if true and doesn't if false
* @return void
*/
public function setMirrorGraphValues($mirrorGraphValues)
{
$this->mirrorGraphValues = $mirrorGraphValues;
}
/**
* Is graph ko
*
@ -1129,9 +1204,6 @@ class DolGraph
else {
$type = 'bar';
$isfunnel = false;
if ($file == 'idgraphleadfunnel') $isfunnel = true;
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar';
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar';
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line';
@ -1141,7 +1213,7 @@ class DolGraph
$this->stringtoshow .= 'legend: { display: false }, ';
}
$this->stringtoshow .= 'scales: { xAxes: [{ ';
if ($isfunnel) { // FIXME Remove isfunnel by introducing a method hideXValues() on dolgraph
if ($this->hideXValues) {
$this->stringtoshow .= ' ticks: { display: false }, display: true,';
}
//$this->stringtoshow .= 'type: \'time\', '; // Need Moment.js
@ -1156,17 +1228,23 @@ class DolGraph
}
$this->stringtoshow .= ' }] }';
// Add a callback to change label to show only positive value
if ($isfunnel) {
if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
$this->stringtoshow .= ', tooltips: { mode: \'nearest\',
callbacks: {
title: function(tooltipItem, data) {
return data.datasets[tooltipItem[0].datasetIndex].label;
},
label: function(tooltipItem, data) {
return data.datasets[tooltipItem.datasetIndex].data[0][1];
}
}
},';
callbacks: {';
if (is_array($this->tooltipsTitles)) {
$this->stringtoshow .='
title: function(tooltipItem, data) {
var tooltipsTitle ='.json_encode($this->tooltipsTitles).'
return tooltipsTitle[tooltipItem[0].datasetIndex];
},';
}
if (is_array($this->tooltipsLabels)) {
$this->stringtoshow .= 'label: function(tooltipItem, data) {
var tooltipslabels ='.json_encode($this->tooltipsLabels).'
return tooltipslabels[tooltipItem.datasetIndex]
}';
}
$this->stringtoshow .='}},';
}
$this->stringtoshow .= '};';
$this->stringtoshow .= '
@ -1180,13 +1258,11 @@ class DolGraph
labels: [';
$i = 0;
if (!$isfunnel) {
foreach ($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', ';
$this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'";
$i++;
}
foreach ($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', ';
$this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
$i++;
}
//var_dump($arrayofgroupslegend);
@ -1196,7 +1272,8 @@ class DolGraph
global $theme_datacolor;
//var_dump($arrayofgroupslegend);
$i = 0; $iinstack = 0;
$i = 0;
$iinstack = 0;
$oldstacknum = -1;
while ($i < $nblot) // Loop on each serie
{
@ -1242,34 +1319,15 @@ class DolGraph
$color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)';
$bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')';
} else { // We do not use a 'group by'
if ($isfunnel) {
$bordercolor == 'null';
if (is_array($this->datacolor[$i])) {
$color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; // If datacolor is array(R, G, B)
} else {
// TODO FIXME This logic must be in the caller that set $this->datacolor
$tmp = str_replace('#', '', $this->datacolor[$i]);
if (strpos($tmp, '-') !== false) {
$foundnegativecolor++;
$color = '#FFFFFF'; // If $val is '-123'
} else {
$color = "#" . $tmp; // If $val is '123' or '#123'
$bordercolor = $color;
}
if ($foundnegativecolor) {
if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B)
else {
$tmp = str_replace('#', '', $this->datacolor[$i]);
if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123'
else $bordercolor = 'null'; // If $val is '123' or '#123'
}
}
}
$bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'";
if (is_array($this->datacolor[$i])) {
$color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)';
} else {
$color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].', 0.9)';
$color = $this->datacolor[$i];
}
if (is_array($this->bordercolor[$i])) {
$bordercolor = $color;
//$color = (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor));
} else {
$bordercolor = $this->bordercolor[$i];
}
}
@ -1280,21 +1338,16 @@ class DolGraph
$this->stringtoshow .= 'label: \'' . dol_escape_js(dol_string_nohtmltag($textoflegend)) . '\', ';
$this->stringtoshow .= 'pointStyle: \'' . ((!empty($this->type[$i]) && $this->type[$i] == 'linesnopoint') ? 'line' : 'circle') . '\', ';
$this->stringtoshow .= 'fill: ' . ($type == 'bar' ? 'true' : 'false') . ', ';
if ($isfunnel) {
$this->stringtoshow .= 'borderWidth: \'2\', ';
} elseif ($type == 'bar' || $type == 'horizontalBar') {
$this->stringtoshow .= 'borderWidth: \'1\', ';
if ($type == 'bar' || $type == 'horizontalBar') {
$this->stringtoshow .= 'borderWidth: \''.$this->borderwidth.'\', ';
}
$this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', ';
$this->stringtoshow .= 'backgroundColor: \'' . $color . '\', ';
if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
$this->stringtoshow .='data: [';
if ($isfunnel) {
$this->stringtoshow .= '['.-$serie[$i].','.$serie[$i].']';
} else {
$this->stringtoshow .= $serie[$i];
}
$this->stringtoshow .=']';
$this->stringtoshow .= 'data: [';
$this->stringtoshow .= $this->mirrorGraphValues ? '[' . -$serie[$i] . ',' . $serie[$i] . ']' : $serie[$i];
$this->stringtoshow .= ']';
$this->stringtoshow .= '}' . "\n";
$i++;
@ -1318,7 +1371,7 @@ class DolGraph
{
$value = 0;
foreach ($this->data as $valarray) // Loop on each x
{
{
$value += $valarray[1];
}
return $value;
@ -1361,13 +1414,11 @@ class DolGraph
{
global $conf;
if ($direction == 'width')
{
if ($direction == 'width') {
if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500');
else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40));
}
if ($direction == 'height')
{
if ($direction == 'height') {
return (empty($conf->dol_optimize_smallscreen) ? ($defaultsize ? $defaultsize : '200') : '160');
}
return 0;

View File

@ -1031,7 +1031,7 @@ class FormCompany extends Form
$out .= '<input type="hidden" name="action" value="set_thirdpartytype">';
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
$sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
$out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 0, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
$out .= $this->selectarray($htmlname, $this->typent_array(0, $filter), $selected, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
$out .= '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans("Modify").'">';
$out .= '</form>';
} else {

View File

@ -16,6 +16,7 @@
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Thibault Foucart <support@ptibogxiv.net>
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -1771,7 +1772,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
} else {
$morehtmlstatus .= '<span class="statusrefbuy">'.$object->getLibStatut(6, 1).'</span>';
}
} elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
} elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva'))) {
$tmptxt = $object->getLibStatut(6, $object->totalpaye);
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5, $object->totalpaye);
$morehtmlstatus .= $tmptxt;
@ -3363,7 +3364,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
} else {
$fakey = 'fa-'.$pictowithouttext;
}
if (in_array($pictowithouttext, array('contract'))) {
if (in_array($pictowithouttext, array('member', 'contract'))) {
$fasize = '0.92em';
}
if (in_array($pictowithouttext, array('intervention', 'payment', 'loan'))) {

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -37,7 +38,7 @@ function vat_prepare_head($object)
$head = array();
$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
$head[$tab][1] = $langs->trans('VATPayment');
$head[$tab][1] = $langs->trans('VATDeclaration');
$head[$tab][2] = 'card';
$tab++;

View File

@ -6,6 +6,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -1107,6 +1108,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) {
$newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
$newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/payments.php?mode=tvaonly&amp;leftmenu=tax_vat", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
$newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);

View File

@ -172,7 +172,11 @@ class pdf_standard extends ModelePDFProduct
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
$nblines = count($object->lines);
if (is_array($object->lines)) {
$nblines = count($object->lines);
} else {
$nblines = 0;
}
if ($conf->product->dir_output)
{

View File

@ -274,7 +274,7 @@ if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_tracking) $sql .= natural_search("e.tracking_number", $search_tracking);
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
if ($search_user > 0)
{
@ -339,6 +339,7 @@ if ($resql)
if ($search_tracking) $param .= "&amp;search_tracking=".urlencode($search_tracking);
if ($search_town) $param .= '&search_town='.urlencode($search_town);
if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
@ -490,7 +491,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
// Weight

View File

@ -595,7 +595,7 @@ if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user);
@ -680,6 +680,8 @@ if ($resql)
if ($search_billed != '') $param .= "&search_billed=".urlencode($search_billed);
if ($show_files) $param .= '&show_files='.urlencode($show_files);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -875,7 +877,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
// Date order

View File

@ -533,7 +533,7 @@ if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_type_thirdparty != '' && $search_type_thirdparty >= 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_montant_ht != '') $sql .= natural_search('f.total_ht', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql .= natural_search('f.total_tva', $search_montant_vat, 1);
if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1);
@ -678,6 +678,7 @@ if ($resql)
if ($option) $param .= "&option=".urlencode($option);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_categ_sup > 0) $param .= '&search_categ_sup='.urlencode($search_categ_sup);
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -920,7 +921,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
// Condition of payment
@ -1301,7 +1302,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="center">';
if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
if (empty($typenArray)) $typenArray = $formcompany->typent_array(1);
print $typenArray[$obj->typent_code];
print '</td>';
if (!$i) $totalarray['nbfield']++;

View File

@ -32,7 +32,6 @@
delete from llx_c_typent;
-- Entries for all countries
insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 0, 'TE_UNKNOWN', '-', NULL, 1);
insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 1, 'TE_STARTUP', 'Start-up', NULL, 0);
insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 2, 'TE_GROUP', 'Grand groupe', NULL, 1);
insert into llx_c_typent (id,code,libelle,fk_country,active) values ( 3, 'TE_MEDIUM', 'PME/PMI', NULL, 1);

View File

@ -119,12 +119,44 @@ ALTER TABLE llx_societe CHANGE fk_entrepot fk_warehouse INTEGER DEFAULT NULL;
--ALTER TABLE llx_societe ADD CONSTRAINT fk_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
ALTER TABLE llx_societe ADD INDEX idx_societe_warehouse(fk_warehouse);
-- VMYSQL4.3 ALTER TABLE llx_societe MODIFY COLUMN fk_typent integer NULL;
-- VPGSQL8.2 ALTER TABLE llx_societe ALTER COLUMN fk_typent DROP NOT NULL;
UPDATE llx_societe SET fk_typent=NULL WHERE fk_typent=0;
DELETE FROM llx_c_typent WHERE code='TE_UNKNOWN';
ALTER TABLE llx_socpeople MODIFY poste varchar(255);
ALTER TABLE llx_menu ADD COLUMN prefix varchar(255) NULL AFTER titre;
ALTER TABLE llx_chargesociales ADD COLUMN fk_user integer DEFAULT NULL;
ALTER TABLE llx_fichinter ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
ALTER TABLE llx_projet ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
create table llx_payment_vat
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_tva integer,
datec datetime, -- date de creation
tms timestamp,
datep datetime, -- payment date
amount double(24,8) DEFAULT 0,
fk_typepaiement integer NOT NULL,
num_paiement varchar(50),
note text,
fk_bank integer NOT NULL,
fk_user_creat integer, -- creation user
fk_user_modif integer -- last modification user
)ENGINE=innodb;
ALTER TABLE llx_tva ADD COLUMN paye smallint default 1 NOT NULL;
ALTER TABLE llx_tva ADD COLUMN fk_account integer;
--INSERT INTO llx_payment_vat (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) SELECT rowid, NOW(), datep, amount, COALESCE(fk_typepayment, 0), num_payment, '', fk_bank, fk_user_creat, fk_user_modif FROM llx_tva;
--UPDATE llx_bank_url as url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET url.type = 'vat', url.label = CONCAT('(', tva.label, ')') WHERE type = 'payment_vat';
--INSERT INTO llx_bank_url (fk_bank, url_id, url, label, type) SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_payment_vat ptva on (ptva.fk_bank = b.fk_bank) WHERE type = 'vat';
--ALTER TABLE llx_tva DROP COLUMN fk_bank;
ALTER TABLE llx_tva ALTER COLUMN paye SET DEFAULT 0;

View File

@ -0,0 +1,35 @@
-- ===================================================================
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
--
-- 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 <https://www.gnu.org/licenses/>.
--
-- ===================================================================
create table llx_payment_vat
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_tva integer,
datec datetime, -- date de creation
tms timestamp,
datep datetime, -- payment date
amount double(24,8) DEFAULT 0,
fk_typepaiement integer NOT NULL,
num_paiement varchar(50),
note text,
fk_bank integer NOT NULL,
fk_user_creat integer, -- creation user
fk_user_modif integer -- last modification user
)ENGINE=innodb;

View File

@ -63,7 +63,7 @@ create table llx_societe
whatsapp varchar(255), -- deprecated
fk_effectif integer DEFAULT 0, --
fk_typent integer DEFAULT 0, --
fk_typent integer DEFAULT NULL, -- type ent
fk_forme_juridique integer DEFAULT 0, -- juridical status
fk_currency varchar(3), -- default currency
siren varchar(128), -- IDProf1: depends on country (example: siren or RCS for france, ...)

View File

@ -30,7 +30,8 @@ create table llx_tva
label varchar(255),
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text,
fk_bank integer,
paye smallint default 0 NOT NULL,
fk_account integer,
fk_user_creat integer, -- utilisateur who create record
fk_user_modif integer, -- utilisateur who modify record
import_key varchar(14)

View File

@ -494,12 +494,14 @@ Cash=Cash
Reported=Delayed
DisabledBecausePayments=Not possible since there are some payments
CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least one invoice classified paid
CantRemovePaymentVATPaid=Can't remove payment since VAT declaration is classified paid
ExpectedToPay=Expected payment
CantRemoveConciliatedPayment=Can't remove reconciled payment
PayedByThisPayment=Paid by this payment
ClosePaidInvoicesAutomatically=Classify automatically all standard, down payment or replacement invoices as "Paid" when payment is done entirely.
ClosePaidCreditNotesAutomatically=Classify automatically all credit notes as "Paid" when refund is done entirely.
ClosePaidContributionsAutomatically=Classify automatically all social or fiscal contributions as "Paid" when payment is done entirely.
ClosePaidVATAutomatically=Classify automatically VAT declaration as "Paid" when payment is done entirely.
AllCompletelyPayedInvoiceWillBeClosed=All invoices with no remainder to pay will be automatically closed with status "Paid".
ToMakePayment=Pay
ToMakePaymentBack=Pay back

View File

@ -65,6 +65,7 @@ LT2SupplierIN=SGST purchases
VATCollected=VAT collected
StatusToPay=To pay
SpecialExpensesArea=Area for all special payments
VATExpensesArea=Area for all TVA payments
SocialContribution=Social or fiscal tax
SocialContributions=Social or fiscal taxes
SocialContributionsDeductibles=Deductible social or fiscal taxes
@ -85,6 +86,7 @@ PaymentCustomerInvoice=Customer invoice payment
PaymentSupplierInvoice=vendor invoice payment
PaymentSocialContribution=Social/fiscal tax payment
PaymentVat=VAT payment
AutomaticCreationPayment=Automatically create a total payment
ListPayment=List of payments
ListOfCustomerPayments=List of customer payments
ListOfSupplierPayments=List of vendor payments
@ -104,6 +106,8 @@ LT2PaymentES=IRPF Payment
LT2PaymentsES=IRPF Payments
VATPayment=Sales tax payment
VATPayments=Sales tax payments
VATDeclarations=VAT declarations
VATDeclaration=VAT declaration
VATRefund=Sales tax refund
NewVATPayment=New sales tax payment
NewLocalTaxPayment=New tax %s payment
@ -134,9 +138,13 @@ NoWaitingChecks=No checks awaiting deposit.
DateChequeReceived=Check reception date
NbOfCheques=No. of checks
PaySocialContribution=Pay a social/fiscal tax
ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid?
PayVAT=Pay a VAT declaration
ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid ?
ConfirmPayVAT=Are you sure you want to classify this VAT declaration as paid ?
DeleteSocialContribution=Delete a social or fiscal tax payment
ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment?
DeleteVAT=Delete a VAT declaration
ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment ?
ConfirmDeleteVAT=Are you sure you want to delete this VAT declaration ?
ExportDataset_tax_1=Social and fiscal taxes and payments
CalcModeVATDebt=Mode <b>%sVAT on commitment accounting%s</b>.
CalcModeVATEngagement=Mode <b>%sVAT on incomes-expenses%s</b>.
@ -235,6 +243,7 @@ ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on thi
ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for vendor third parties
ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated vendor accounting account on third party is not defined.
ConfirmCloneTax=Confirm the clone of a social/fiscal tax
ConfirmCloneVAT=Confirm the clone of a VAT declaration
CloneTaxForNextMonth=Clone it for next month
SimpleReport=Simple report
AddExtraReport=Extra reports (add foreign and national customer report)
@ -253,7 +262,8 @@ AccountingAffectation=Accounting assignment
LastDayTaxIsRelatedTo=Last day of period the tax is related to
VATDue=Sale tax claimed
ClaimedForThisPeriod=Claimed for the period
PaidDuringThisPeriod=Paid during this period
PaidDuringThisPeriod=Paid for this period
PaidDuringThisPeriodDesc=This is the sum of all payments linked to VAT declarations which have an end-of-period date in the selected date range
ByVatRate=By sale tax rate
TurnoverbyVatrate=Turnover invoiced by sale tax rate
TurnoverCollectedbyVatrate=Turnover collected by sale tax rate

View File

@ -191,7 +191,8 @@ if (!empty($action) && $action == 'fetch' && !empty($id))
'pricebasetype' => $outpricebasetype,
'tva_tx' => $outtva_tx,
'qty' => $outqty,
'discount' => $outdiscount);
'discount' => $outdiscount,
'array_option'=>$object->array_options);
}
echo json_encode($outjson);

View File

@ -447,7 +447,7 @@ if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_ref_rcp) $sql .= natural_search('e.ref', $search_ref_rcp);
if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
if ($search_company) $sql .= natural_search('s.nom', $search_company);
@ -656,7 +656,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
// Date delivery planned

View File

@ -1497,7 +1497,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Type - Workforce/Staff
print '<tr><td>'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'."\n";
$sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td>';
if ($conf->browser->layout == 'phone') print '</tr><tr>';
@ -2173,7 +2173,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Type - Workforce/Staff
print '<tr><td>'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print '</td>';
if ($conf->browser->layout == 'phone') print '</tr><tr>';

View File

@ -485,7 +485,7 @@ if ($search_type == '0') $sql .= " AND s.client = 0 AND s.fournisseur = 0";
if ($search_status != '' && $search_status >= 0) $sql .= natural_search("s.status", $search_status, 2);
if (!empty($conf->barcode->enabled) && $search_barcode) $sql .= natural_search("s.barcode", $search_barcode);
if ($search_prive_level && $search_prive_level != '-1') $sql .= natural_search("s.price_level", $search_prive_level, 2);
if ($search_type_thirdparty && $search_type_thirdparty != '-1') $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
if ($search_type_thirdparty && $search_type_thirdparty > 0) $sql .= natural_search("s.fk_typent", $search_type_thirdparty, 2);
if (!empty($search_staff) && $search_staff != '-1') $sql .= natural_search("s.fk_effectif", $search_staff, 2);
if ($search_level) $sql .= natural_search("s.fk_prospectlevel", join(',', $search_level), 3);
if ($search_parent_name) $sql .= natural_search("s2.nom", $search_parent_name);
@ -582,7 +582,7 @@ if ($search_idprof5 != '') $param .= '&search_idprof5='.urlencode($search_idprof
if ($search_idprof6 != '') $param .= '&search_idprof6='.urlencode($search_idprof6);
if ($search_vat != '') $param .= '&search_vat='.urlencode($search_vat);
if ($search_prive_level != '') $param .= '&search_prive_level='.urlencode($search_prive_level);
if ($search_type_thirdparty != '') $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($search_type != '') $param .= '&search_type='.urlencode($search_type);
if (is_array($search_level) && count($search_level)) foreach ($search_level as $slevel) $param .= '&search_level[]='.urlencode($slevel);
if ($search_status != '') $param .= '&search_status='.urlencode($search_status);

View File

@ -294,7 +294,7 @@ if ($search_town) $sql .= natural_search('s.town', $search_town);
if ($search_zip) $sql .= natural_search("s.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);
if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
if ($search_ref) $sql .= natural_search('sp.ref', $search_ref);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_login) $sql .= natural_search('u.login', $search_login);
@ -395,6 +395,7 @@ if ($resql)
if ($socid > 0) $param .= '&socid='.urlencode($socid);
if ($search_status != '') $param .= '&search_status='.urlencode($search_status);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -518,7 +519,7 @@ if ($resql)
if (!empty($arrayfields['typent.code']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone center">';
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
print '</td>';
}
// Date