26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/compta/localtax/class/localtax.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/vat.lib.php';
32 $langs->loadLangs(array(
'compta',
'banks',
'bills'));
35 $action =
GETPOST(
"action",
"alpha");
36 $refund =
GETPOST(
"refund",
"int");
37 if (empty($refund)) $refund = 0;
39 $lttype =
GETPOST(
'localTaxType',
'int');
42 $socid =
GETPOST(
'socid',
'int');
43 if ($user->socid) $socid = $user->socid;
49 $hookmanager->initHooks(array(
'localtaxvatcard',
'globalcard'));
56 if ($_POST[
"cancel"] == $langs->trans(
"Cancel") && !$id)
58 header(
"Location: list.php?localTaxType=".$lttype);
62 if ($action ==
'add' && $_POST[
"cancel"] <> $langs->trans(
"Cancel"))
66 $datev =
dol_mktime(12, 0, 0, $_POST[
"datevmonth"], $_POST[
"datevday"], $_POST[
"datevyear"]);
67 $datep =
dol_mktime(12, 0, 0, $_POST[
"datepmonth"], $_POST[
"datepday"], $_POST[
"datepyear"]);
69 $object->accountid =
GETPOST(
"accountid");
70 $object->paymenttype =
GETPOST(
"paiementtype");
71 $object->datev = $datev;
72 $object->datep = $datep;
74 $object->label =
GETPOST(
"label");
75 $object->ltt = $lttype;
77 $ret = $object->addPayment($user);
81 header(
"Location: list.php?localTaxType=".$lttype);
86 $_GET[
"action"] =
"create";
91 if ($action ==
'delete')
93 $result = $object->fetch($id);
95 if ($object->rappro == 0)
99 $ret = $object->delete($user);
102 if ($object->fk_bank)
105 $result = $accountline->fetch($object->fk_bank);
106 if ($result > 0) $result = $accountline->delete($user);
112 header(
"Location: ".DOL_URL_ROOT.
'/compta/localtax/list.php?localTaxType='.$object->ltt);
115 $object->error = $accountline->error;
124 $mesg =
'Error try do delete a line linked to a conciliated bank transaction';
136 $result = $object->fetch($id);
146 $title = $langs->trans(
"LT".$object->ltt).
" - ".$langs->trans(
"Card");
150 if ($action ==
'create')
152 print load_fiche_titre($langs->transcountry($lttype == 2 ?
"newLT2Payment" :
"newLT1Payment", $mysoc->country_code));
154 print '<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" name="formlocaltax" method="post">'.
"\n";
155 print '<input type="hidden" name="token" value="'.newToken().
'">';
156 print '<input type="hidden" name="localTaxType" value="'.$lttype.
'">';
157 print '<input type="hidden" name="action" value="add">';
161 print '<table class="border centpercent">';
164 print '<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"DatePayment").
'</td><td>';
165 print $form->selectDate($datep,
"datep",
'',
'',
'',
'add', 1, 1);
168 print '<tr><td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"PeriodEndDate"), $langs->trans(
"LastDayTaxIsRelatedTo")).
'</td><td>';
169 print $form->selectDate($datev,
"datev",
'',
'',
'',
'add', 1, 1);
173 print '<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td><input name="label" class="minwidth200" value="'.($_POST[
"label"] ?
GETPOST(
"label",
'', 2) : $langs->transcountry(($lttype == 2 ?
"LT2Payment" :
"LT1Payment"), $mysoc->country_code)).
'"></td></tr>';
176 print '<tr><td class="fieldrequired">'.$langs->trans(
"Amount").
'</td><td><input name="amount" size="10" value="'.
GETPOST(
"amount").
'"></td></tr>';
178 if (!empty($conf->banque->enabled))
180 print '<tr><td class="fieldrequired">'.$langs->trans(
"Account").
'</td><td>';
181 $form->select_comptes($_POST[
"accountid"],
"accountid", 0,
"courant=1", 2);
184 print '<tr><td class="fieldrequired">'.$langs->trans(
"PaymentMode").
'</td><td>';
185 $form->select_types_paiements(
GETPOST(
"paiementtype"),
"paiementtype");
190 print '<tr><td>'.$langs->trans(
'Numero');
191 print ' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
192 print '<td><input name="num_payment" type="text" value="'.GETPOST(
"num_payment").
'"></td></tr>'.
"\n";
195 $parameters = array();
196 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
197 print $hookmanager->resPrint;
203 print '<div class="center">';
204 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
205 print ' ';
206 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
217 $head[$h][0] = DOL_URL_ROOT.
'/compta/localtax/card.php?id='.$object->id;
218 $head[$h][1] = $langs->trans(
'Card');
219 $head[$h][2] =
'card';
222 print dol_get_fiche_head($head,
'card', $langs->transcountry(
"LT".$object->ltt, $mysoc->country_code), -1,
'payment');
224 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/localtax/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
226 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref,
'', 0,
'',
'');
228 print '<div class="fichecenter">';
229 print '<div class="underbanner clearboth"></div>';
231 print '<table class="border centpercent">';
234 print '<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
239 print '<td>'.$langs->trans(
"DatePayment").
'</td><td>';
243 print '<tr><td>'.$form->textwithpicto($langs->trans(
"PeriodEndDate"), $langs->trans(
"LastDayTaxIsRelatedTo")).
'</td><td>';
247 print '<tr><td>'.$langs->trans(
"Amount").
'</td><td>'.
price($object->amount).
'</td></tr>';
249 if (!empty($conf->banque->enabled))
251 if ($object->fk_account > 0)
254 $bankline->fetch($object->fk_bank);
257 print '<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
259 print $bankline->getNomUrl(1, 0,
'showall');
266 $parameters = array();
267 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
268 print $hookmanager->resPrint;
280 print "<div class=\"tabsAction\">\n";
281 if ($object->rappro == 0)
283 print '<a class="butActionDelete" href="card.php?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
"Delete").
'</a>';
285 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"LinkedToAConcialitedTransaction").
'">'.$langs->trans(
"Delete").
'</a>';
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.
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).
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.
Class to manage local tax.
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.