28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/vat.lib.php';
34 $langs->loadLangs(array(
'compta',
'banks',
'bills'));
37 $action=
GETPOST(
"action",
"alpha");
38 $refund=
GETPOST(
"refund",
"int");
39 if (empty($refund)) $refund=0;
42 $socid =
GETPOST(
'socid',
'int');
43 if ($user->societe_id) $socid=$user->societe_id;
46 $object =
new Tva($db);
49 $hookmanager->initHooks(array(
'taxvatcard',
'globalcard'));
56 if ($_POST[
"cancel"] == $langs->trans(
"Cancel") && ! $id)
58 header(
"Location: list.php");
62 if ($action ==
'setlib' && $user->rights->tax->charges->creer)
65 $result = $object->setValueFrom(
'label',
GETPOST(
'lib',
'alpha'),
'',
'',
'text',
'', $user,
'TAX_MODIFY');
70 if ($action ==
'setdatev' && $user->rights->tax->charges->creer)
74 $result=$object->update($user);
80 if ($action ==
'add' && $_POST[
"cancel"] <> $langs->trans(
"Cancel"))
84 $datev=
dol_mktime(12,0,0, $_POST[
"datevmonth"], $_POST[
"datevday"], $_POST[
"datevyear"]);
85 $datep=
dol_mktime(12,0,0, $_POST[
"datepmonth"], $_POST[
"datepday"], $_POST[
"datepyear"]);
87 $object->accountid=
GETPOST(
"accountid");
88 $object->type_payment=
GETPOST(
"type_payment");
89 $object->num_payment=
GETPOST(
"num_payment");
90 $object->datev=$datev;
91 $object->datep=$datep;
97 $object->amount= $amount;
98 $object->label=
GETPOST(
"label",
'alpha');
99 $object->note=
GETPOST(
"note",
'none');
101 if (empty($object->datev))
103 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateValue")), null,
'errors');
106 if (empty($object->datep))
108 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePayment")), null,
'errors');
111 if (empty($object->type_payment) || $object->type_payment < 0)
113 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")), null,
'errors');
116 if (empty($object->amount))
118 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")), null,
'errors');
126 $ret=$object->addPayment($user);
130 header(
"Location: list.php");
144 if ($action ==
'delete')
146 $result=$object->fetch($id);
148 if ($object->rappro == 0)
152 $ret=$object->delete($user);
155 if ($object->fk_bank)
158 $result=$accountline->fetch($object->fk_bank);
159 if ($result > 0) $result=$accountline->delete($user);
165 header(
"Location: ".DOL_URL_ROOT.
'/compta/tva/list.php');
170 $object->error=$accountline->error;
183 $mesg=
'Error try do delete a line linked to a conciliated bank transaction';
195 $title=$langs->trans(
"VAT") .
" - " . $langs->trans(
"Card");
202 $result = $object->fetch($id);
211 if ($action ==
'create')
215 if (! empty($conf->use_javascript_ajax))
217 print "\n".
'<script type="text/javascript" language="javascript">';
218 print '$(document).ready(function () { 219 $("#radiopayment").click(function() { 220 $("#label").val($(this).data("label")); 223 $("#radiorefund").click(function() { 224 $("#label").val($(this).data("label")); 228 print '</script>'.
"\n";
231 print '<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" name="formvat" method="post">';
232 print '<input type="hidden" name="token" value="'.$_SESSION[
'newtoken'].
'">';
233 print '<input type="hidden" name="action" value="add">';
235 print '<div id="selectmethod">';
236 print '<div class="hideonsmartphone float">';
237 print $langs->trans(
"Type").
': ';
239 print '<label for="radiopayment">';
240 print '<input type="radio" id="radiopayment" data-label="'.$langs->trans(
'VATPayment').
'" class="flat" name="refund" value="0"'.($refund?
'':
' checked="checked"').
'>';
242 print $langs->trans(
"Payment");
244 print ' ';
245 print '<label for="radiorefund">';
246 print '<input type="radio" id="radiorefund" data-label="'.$langs->trans(
'VATRefund').
'" class="flat" name="refund" value="1"'.($refund?
' checked="checked"':
'').
'>';
248 print $langs->trans(
"Refund");
255 print '<table class="border" width="100%">';
258 print '<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
259 print $form->selectDate($datep,
"datep",
'',
'',
'',
'add', 1, 1);
262 print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PeriodEndDate"), $langs->trans(
"LastDayTaxIsRelatedTo")).
'</td><td>';
263 print $form->selectDate($datev,
"datev",
'',
'',
'',
'add', 1, 1);
268 $label = $langs->trans(
"VATRefund");
270 $label = $langs->trans(
"VATPayment");
272 print '<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td><input class="minwidth300" name="label" id="label" value="'.($_POST[
"label"]?
GETPOST(
"label",
'',2):$label).
'"></td></tr>';
275 print '<tr><td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input name="amount" size="10" value="'.
GETPOST(
"amount",
"alpha").
'"></td></tr>';
277 if (! empty($conf->banque->enabled))
279 print '<tr><td class="fieldrequired">'.$langs->trans(
"BankAccount").
'</td><td>';
280 $form->select_comptes($_POST[
"accountid"],
"accountid",0,
"courant=1",1);
285 print '<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
286 $form->select_types_paiements(
GETPOST(
"type_payment"),
"type_payment");
291 print '<tr><td>'.$langs->trans(
'Numero');
292 print ' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
293 print '<td><input name="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
297 $reshook=$hookmanager->executeHooks(
'formObjectOptions',
$parameters,$object,$action);
298 print $hookmanager->resPrint;
304 print '<div class="center">';
305 print '<input type="submit" class="button" value="'.$langs->trans(
"Save").
'">';
306 print ' ';
307 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
318 dol_fiche_head($head,
'card', $langs->trans(
"VATPayment"), -1,
'payment');
320 $morehtmlref=
'<div class="refidno">';
322 $morehtmlref.=
$form->editfieldkey(
"Label",
'lib', $object->label, $object, $user->rights->tax->charges->creer,
'string',
'', 0, 1);
323 $morehtmlref.=
$form->editfieldval(
"Label",
'lib', $object->label, $object, $user->rights->tax->charges->creer,
'string',
'', null, null,
'', 1);
325 $morehtmlref.=
'</div>';
327 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/tva/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
329 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
331 print '<div class="fichecenter">';
332 print '<div class="underbanner clearboth"></div>';
334 print '<table class="border" width="100%">';
340 print '<td class="titlefield">'.$langs->trans(
"DatePayment").
'</td><td>';
345 print $form->editfieldkey(
$form->textwithpicto($langs->trans(
"PeriodEndDate"), $langs->trans(
"LastDayTaxIsRelatedTo")),
'datev', $object->datev, $object, $user->rights->tax->charges->creer,
'day');
347 print $form->editfieldval(
"PeriodEndDate",
'datev', $object->datev, $object, $user->rights->tax->charges->creer,
'day');
351 print '<tr><td>'.$langs->trans(
"Amount").
'</td><td>'.
price($object->amount).
'</td></tr>';
353 if (! empty($conf->banque->enabled))
355 if ($object->fk_account > 0)
358 $bankline->fetch($object->fk_bank);
361 print '<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
363 print $bankline->getNomUrl(1,0,
'showall');
371 $reshook=$hookmanager->executeHooks(
'formObjectOptions',
$parameters,$object,$action);
372 print $hookmanager->resPrint;
383 print "<div class=\"tabsAction\">\n";
384 if ($object->rappro == 0)
386 if (! empty($user->rights->tax->charges->supprimer))
388 print '<a class="butActionDelete" href="card.php?id='.$object->id.
'&action=delete">'.$langs->trans(
"Delete").
'</a>';
392 print '<a class="butActionRefused" href="#" title="'.(dol_escape_htmltag($langs->trans(
"NotAllowed"))).
'">'.$langs->trans(
"Delete").
'</a>';
397 print '<a class="butActionRefused" href="#" title="'.$langs->trans(
"LinkedToAConciliatedTransaction").
'">'.$langs->trans(
"Delete").
'</a>';
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Class to manage bank transaction lines.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Put here description of your class.
dol_fiche_end($notab=0)
Show tab footer of a card.
if($_POST["cancel"]==$langs->trans("Cancel") &&! $id) if($action=='add' && $_POST["cancel"]<> $langs->trans("Cancel")) if($action=='delete') if($id) $form
Actions.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
vat_prepare_head($object)
Prepare array with list of tabs.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is '...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.