Files
dolibarr/htdocs/compta/localtax/card.php
MDW 7b54824d49 Fix #28071 - New branch to fix bad merge (#28083)
* Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

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

* Qual: Introduce getDataToShowPhoto to prepare generic code

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

* Fix missing trans

* Fix langs

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

* Remove useless files in web templates

* Clean code

* Fix duplicate translation key

* Fix duplicate translation key

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

* Fix duplicate key

* Fix $object

* Debug v19

* WIP SMSing

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

* WIP EMAILINGS_SUPPORT_ALSO_SMS

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

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

* WIP SMSing

* Debug the "validate" feature

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

* Clean code

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

* Move rights->x->y into hasRight('x', 'y')

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

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

* Enhance rector to fix empty($user->rights->modulex->perm1)

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

* Fix template to use v19 dev rules

* Fix use v19 dev rules

* Fix phpunit

* Debug v19

* Clean code

* Use rector to convert user->rights into user->hasRight

* Clean code

* Use rector to convert user->rights into user->hasRight

* Use rector to convert user->rights into user->hasRight

* Clean code

* Fix phpcs

* add editorconfig for sql files (#27999)

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>

* add model_pdf field in llx_ticket-ticket.sql (#27996)

* add model_pdf field in llx_ticket-ticket.sql

* Update 19.0.0-20.0.0.sql

* Update 19.0.0-20.0.0.sql

* Improve wording in README (#27994)

* fix phpstan (#27989)

* fix phpstan

* Update UserRightsToFunction.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>

* Qual: Fix spelling/working in datapolicy translations (#28006)

# Qual: Fix spelling/wording in datapolicy translations

Fixed some spelling and wording in datapolicy translations.

* qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986)

htdocs/ticket/class/ticketstats.class.php	98	Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth()

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

* Fix user with readonly perm on email template must be able to read.

* Fix doc

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

* Better message

* Add missing fields in merge of thirdparty

* Debug v19 selection of ticket printer per terminal

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

* Use constant

* NEW: Adding a recipient on emails sent, change status to sent partialy.

* fix travis (#28052)

* fix travis

* Update partnership.class.php

* fix php doc (#28047)

* fix undefined array key (#28048)

* Add region and departament for Cuba (#28046)

* Update llx_10_c_regions.sql

Add Cuba Regions (id_country=77)

* Update llx_20_c_departements.sql

Add Provinces Cuba (id country=77)

* Find the typo (#28050)

* Find the typo

* clean code

* add last_main_doc field to product (#28045)

* add las_main_doc field to product

* add field fetch

* NEW Add Categorie filter for ActionComm (#28041)

* New Add Categorie filter for ActionComm

New Add Categorie filter for ActionComm

* Fix space errors

Fix space errors

* Fix space errors 2

Fix space errors 2

* Update cunits.class.php (#28056)

FIX: error SQL when creating a Cunit

* Update codespell-lines-ignore.txt to avoid PR merge conflict

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com>
Co-authored-by: thibdrev <thibault.drevet@gmail.com>
Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com>
Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com>
Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com>
Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 15:58:49 +01:00

291 lines
9.2 KiB
PHP

<?php
/* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.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/localtax/card.php
* \ingroup tax
* \brief Page of second or third tax payments (like IRPF for spain, ...)
*/
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('compta', 'banks', 'bills'));
$id = GETPOST("id", 'int');
$action = GETPOST("action", "aZ09");
$cancel = GETPOST('cancel', 'aZ09');
$refund = GETPOST("refund", "int");
if (empty($refund)) {
$refund = 0;
}
$lttype = GETPOST('localTaxType', 'int');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'tax', '', '', 'charges');
$object = new Localtax($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('localtaxvatcard', 'globalcard'));
/**
* Actions
*/
if ($cancel && !$id) {
header("Location: list.php?localTaxType=".$lttype);
exit;
}
if ($action == 'add' && !$cancel) {
$db->begin();
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
$datep = dol_mktime(12, 0, 0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
$object->accountid = GETPOSTINT("accountid");
$object->paymenttype = GETPOST("paiementtype");
$object->datev = $datev;
$object->datep = $datep;
$object->amount = price2num(GETPOST("amount"));
$object->label = GETPOST("label");
$object->ltt = $lttype;
$ret = $object->addPayment($user);
if ($ret > 0) {
$db->commit();
header("Location: list.php?localTaxType=".$lttype);
exit;
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
$_GET["action"] = "create";
}
}
//delete payment of localtax
if ($action == 'delete') {
$result = $object->fetch($id);
if ($object->rappro == 0) {
$db->begin();
$ret = $object->delete($user);
if ($ret > 0) {
if ($object->fk_bank) {
$accountline = new AccountLine($db);
$result = $accountline->fetch($object->fk_bank);
if ($result > 0) {
$result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
}
}
if ($result >= 0) {
$db->commit();
header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$object->ltt);
exit;
} 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');
}
}
/*
* View
*/
if ($id) {
$result = $object->fetch($id);
if ($result <= 0) {
dol_print_error($db);
exit;
}
}
$form = new Form($db);
$title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card");
$help_url = '';
llxHeader('', $title, $help_url);
if ($action == 'create') {
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
$datep = dol_mktime(12, 0, 0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code));
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" name="formlocaltax" method="post">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="localTaxType" value="'.$lttype.'">';
print '<input type="hidden" name="action" value="add">';
print dol_get_fiche_head();
print '<table class="border centpercent">';
// Date of payment
print "<tr>";
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1);
print '</td></tr>';
// End date of period
print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).'</td><td>';
print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1);
print '</td></tr>';
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth200" value="'.(GETPOSTISSET("label") ? GETPOST("label", '', 2) : $langs->transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'"></td></tr>';
// Amount
print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input name="amount" size="10" value="'.GETPOST("amount").'"></td></tr>';
if (isModEnabled("banque")) {
// Type payment
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
print $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype", '', 0, 1, 0, 0, 1, 'maxwidth500 widthcentpercentminusx', 1);
print "</td>\n";
print "</tr>";
// Bank account
print '<tr><td class="fieldrequired" id="label_fk_account">'.$langs->trans("BankAccount").'</td><td>';
print img_picto('', 'bank_account', 'pictofixedwidth');
$form->select_comptes(GETPOST("accountid", "int"), "accountid", 0, "courant=1", 2, '', 0, 'maxwidth500 widthcentpercentminusx'); // Affiche liste des comptes courant
print '</td></tr>';
// Number
print '<tr><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;
print '</table>';
print dol_get_fiche_end();
print $form->buttonsSaveCancel();
print '</form>';
}
// View mode
if ($id) {
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$object->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][2] = 'card';
$h++;
print dol_get_fiche_head($head, 'card', $langs->transcountry("LT".$object->ltt, $mysoc->country_code), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/localtax/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print "<tr>";
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->ref;
print '</td></tr>';
print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td>';
print dol_print_date($object->datep, 'day');
print '</td></tr>';
print '<tr><td>'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).'</td><td>';
print dol_print_date($object->datev, 'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
if (isModEnabled("banque")) {
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>';
}
}
// 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 '</table>';
print '</div>';
print dol_get_fiche_end();
/*
* Action bar
*/
print "<div class=\"tabsAction\">\n";
if ($object->rappro == 0) {
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConcialitedTransaction").'">'.$langs->trans("Delete").'</a>';
}
print "</div>";
}
// End of page
llxFooter();
$db->close();