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;
46 $socid =
GETPOST(
'socid',
'int');
47 if ($user->socid) $socid = $user->socid;
50 $object =
new Tva($db);
53 $hookmanager->initHooks(array(
'taxvatcard',
'globalcard'));
60 if ($_POST[
"cancel"] == $langs->trans(
"Cancel") && !$id)
62 header(
"Location: list.php");
66 if ($action ==
'setlib' && $user->rights->tax->charges->creer)
69 $result = $object->setValueFrom(
'label',
GETPOST(
'lib',
'alpha'),
'',
'',
'text',
'', $user,
'TAX_MODIFY');
74 if ($action ==
'setdatev' && $user->rights->tax->charges->creer)
77 $object->datev = $datev;
78 $result = $object->update($user);
84 if ($action ==
'add' && $_POST[
"cancel"] <> $langs->trans(
"Cancel"))
88 $object->accountid =
GETPOST(
"accountid",
'int');
89 $object->type_payment =
GETPOST(
"type_payment",
'alphanohtml');
90 $object->num_payment =
GETPOST(
"num_payment",
'alphanohtml');
92 $object->datev = $datev;
93 $object->datep = $datep;
99 $object->amount = $amount;
100 $object->label =
GETPOST(
"label",
'alpha');
101 $object->note_private =
GETPOST(
"note",
'restricthtml');
103 if (empty($object->datep))
105 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePayment")), null,
'errors');
108 if (empty($object->datev))
110 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PeriodEndDate")), null,
'errors');
113 if (empty($object->type_payment) || $object->type_payment < 0)
115 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"PaymentMode")), null,
'errors');
118 if (empty($object->amount))
120 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Amount")), null,
'errors');
128 $ret = $object->addPayment($user);
132 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');
168 $object->error = $accountline->error;
177 $mesg =
'Error try do delete a line linked to a conciliated bank transaction';
189 $title = $langs->trans(
"VAT").
" - ".$langs->trans(
"Card");
196 $result = $object->fetch($id);
205 if ($action ==
'create')
209 if (!empty($conf->use_javascript_ajax))
211 print "\n".
'<script type="text/javascript" language="javascript">';
212 print '$(document).ready(function () {
213 $("#radiopayment").click(function() {
214 $("#label").val($(this).data("label"));
217 $("#radiorefund").click(function() {
218 $("#label").val($(this).data("label"));
222 print '</script>'.
"\n";
225 print '<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" name="formvat" method="post">';
226 print '<input type="hidden" name="token" value="'.newToken().
'">';
227 print '<input type="hidden" name="action" value="add">';
229 print '<div id="selectmethod">';
230 print '<div class="hideonsmartphone float">';
231 print $langs->trans(
"Type").
': ';
233 print '<label for="radiopayment">';
234 print '<input type="radio" id="radiopayment" data-label="'.$langs->trans(
'VATPayment').
'" class="flat" name="refund" value="0"'.($refund ?
'' :
' checked="checked"').
'>';
236 print $langs->trans(
"Payment");
238 print ' ';
239 print '<label for="radiorefund">';
240 print '<input type="radio" id="radiorefund" data-label="'.$langs->trans(
'VATRefund').
'" class="flat" name="refund" value="1"'.($refund ?
' checked="checked"' :
'').
'>';
242 print $langs->trans(
"PaymentBack");
249 print '<table class="border centpercent">';
252 print '<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
253 print $form->selectDate($datep,
"datep",
'',
'',
'',
'add', 1, 1);
256 print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PeriodEndDate"), $langs->trans(
"LastDayTaxIsRelatedTo")).
'</td><td>';
257 print $form->selectDate((
GETPOST(
"datevmonth",
'int') ? $datev : -1),
"datev",
'',
'',
'',
'add', 1, 1);
262 $label = $langs->trans(
"VATRefund");
264 $label = $langs->trans(
"VATPayment");
266 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>';
269 print '<tr><td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input name="amount" size="10" value="'.
GETPOST(
"amount",
"alpha").
'"></td></tr>';
271 if (!empty($conf->banque->enabled))
273 print '<tr><td class="fieldrequired">'.$langs->trans(
"BankAccount").
'</td><td>';
274 $form->select_comptes(
GETPOST(
"accountid",
'int'),
"accountid", 0,
"courant=1", 2);
279 print '<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
280 $form->select_types_paiements(
GETPOST(
"type_payment"),
"type_payment");
285 print '<tr><td>'.$langs->trans(
'Numero');
286 print ' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
287 print '<td><input name="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
290 $parameters = array();
291 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
292 print $hookmanager->resPrint;
298 print '<div class="center">';
299 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
300 print ' ';
301 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
314 $morehtmlref =
'<div class="refidno">';
316 $morehtmlref .= $form->editfieldkey(
"Label",
'lib', $object->label, $object, $user->rights->tax->charges->creer,
'string',
'', 0, 1);
317 $morehtmlref .= $form->editfieldval(
"Label",
'lib', $object->label, $object, $user->rights->tax->charges->creer,
'string',
'', null, null,
'', 1);
319 $morehtmlref .=
'</div>';
321 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/tva/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
323 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
325 print '<div class="fichecenter">';
326 print '<div class="underbanner clearboth"></div>';
328 print '<table class="border centpercent">';
334 print '<td class="titlefield">'.$langs->trans(
"DatePayment").
'</td><td>';
339 print $form->editfieldkey($form->textwithpicto($langs->trans(
"PeriodEndDate"), $langs->trans(
"LastDayTaxIsRelatedTo")),
'datev', $object->datev, $object, $user->rights->tax->charges->creer,
'day');
341 print $form->editfieldval(
"PeriodEndDate",
'datev', $object->datev, $object, $user->rights->tax->charges->creer,
'day');
345 print '<tr><td>'.$langs->trans(
"Amount").
'</td><td>'.
price($object->amount).
'</td></tr>';
347 if (!empty($conf->banque->enabled))
349 if ($object->fk_account > 0)
352 $bankline->fetch($object->fk_bank);
355 print '<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
357 print $bankline->getNomUrl(1, 0,
'showall');
364 $parameters = array();
365 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
366 print $hookmanager->resPrint;
377 print "<div class=\"tabsAction\">\n";
378 if ($object->rappro == 0)
380 if (!empty($user->rights->tax->charges->supprimer))
382 print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
"Delete").
'</a></div>';
384 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans(
"NotAllowed"))).
'">'.$langs->trans(
"Delete").
'</a></div>';
387 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"LinkedToAConciliatedTransaction").
'">'.$langs->trans(
"Delete").
'</a></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage bank transaction lines.
Put here description of your class.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
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.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $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.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.