25require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
36 public $element =
'localtax';
41 public $table_element =
'localtax';
46 public $picto =
'payment';
85 public $fk_user_creat;
90 public $fk_user_modif;
111 global $conf, $langs;
116 $this->amount = trim($this->amount);
117 $this->label = trim($this->label);
118 $this->note = trim($this->note);
121 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"localtax(";
122 $sql .=
"localtaxtype,";
130 $sql .=
"fk_user_creat,";
131 $sql .=
"fk_user_modif";
132 $sql .=
") VALUES (";
133 $sql .=
" ".((int) $this->ltt).
",";
134 $sql .=
" '".$this->db->idate($this->tms).
"',";
135 $sql .=
" '".$this->db->idate($this->datep).
"',";
136 $sql .=
" '".$this->db->idate($this->datev).
"',";
137 $sql .=
" '".$this->db->escape($this->amount).
"',";
138 $sql .=
" '".$this->db->escape($this->label).
"',";
139 $sql .=
" '".$this->db->escape($this->note).
"',";
140 $sql .=
" ".($this->fk_bank <= 0 ?
"NULL" : (int) $this->fk_bank).
",";
141 $sql .=
" ".((int) $this->fk_user_creat).
",";
142 $sql .=
" ".((int) $this->fk_user_modif);
145 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
146 $resql = $this->db->query($sql);
148 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"localtax");
151 $result = $this->
call_trigger(
'LOCALTAX_CREATE', $user);
161 $this->db->rollback();
165 $this->error =
"Error ".$this->db->lasterror();
166 $this->db->rollback();
180 global $conf, $langs;
185 $this->amount = trim($this->amount);
186 $this->label = trim($this->label);
187 $this->note = trim($this->note);
192 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"localtax SET";
193 $sql .=
" localtaxtype=".((int) $this->ltt).
",";
194 $sql .=
" tms='".$this->db->idate($this->tms).
"',";
195 $sql .=
" datep='".$this->db->idate($this->datep).
"',";
196 $sql .=
" datev='".$this->db->idate($this->datev).
"',";
197 $sql .=
" amount=".price2num($this->amount).
",";
198 $sql .=
" label='".$this->db->escape($this->label).
"',";
199 $sql .=
" note='".$this->db->escape($this->note).
"',";
200 $sql .=
" fk_bank=".(int) $this->fk_bank.
",";
201 $sql .=
" fk_user_creat=".(int) $this->fk_user_creat.
",";
202 $sql .=
" fk_user_modif=".(int) $this->fk_user_modif;
203 $sql .=
" WHERE rowid=".((int) $this->
id);
205 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
206 $resql = $this->db->query($sql);
208 $this->error =
"Error ".$this->db->lasterror();
212 if (!$error && !$notrigger) {
214 $result = $this->
call_trigger(
'LOCALTAX_MODIFY', $user);
225 $this->db->rollback();
241 $sql .=
" t.localtaxtype,";
245 $sql .=
" t.amount,";
247 $sql .=
" t.note as note_private,";
248 $sql .=
" t.fk_bank,";
249 $sql .=
" t.fk_user_creat,";
250 $sql .=
" t.fk_user_modif,";
251 $sql .=
" b.fk_account,";
252 $sql .=
" b.fk_type,";
254 $sql .=
" FROM ".MAIN_DB_PREFIX.
"localtax as t";
255 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON t.fk_bank = b.rowid";
256 $sql .=
" WHERE t.rowid = ".((int) $id);
258 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
259 $resql = $this->db->query($sql);
261 if ($this->db->num_rows($resql)) {
262 $obj = $this->db->fetch_object($resql);
264 $this->
id = $obj->rowid;
265 $this->
ref = $obj->rowid;
266 $this->ltt = $obj->localtaxtype;
267 $this->tms = $this->db->jdate($obj->tms);
268 $this->datep = $this->db->jdate($obj->datep);
269 $this->datev = $this->db->jdate($obj->datev);
270 $this->amount = $obj->amount;
271 $this->label = $obj->label;
272 $this->note = $obj->note_private;
273 $this->note_private = $obj->note_private;
274 $this->fk_bank = $obj->fk_bank;
275 $this->fk_user_creat = $obj->fk_user_creat;
276 $this->fk_user_modif = $obj->fk_user_modif;
277 $this->fk_account = $obj->fk_account;
278 $this->fk_type = $obj->fk_type;
279 $this->rappro = $obj->rappro;
281 $this->db->free($resql);
285 $this->error =
"Error ".$this->db->lasterror();
297 public function delete($user)
300 $result = $this->
call_trigger(
'LOCALTAX_DELETE', $user);
306 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"localtax";
307 $sql .=
" WHERE rowid=".((int) $this->
id);
309 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
310 $resql = $this->db->query($sql);
312 $this->error =
"Error ".$this->db->lasterror();
341 $this->fk_user_creat = $user->id;
342 $this->fk_user_modif = $user->id;
361 $solde = $reglee - ($collectee - $payee);
376 $sql =
"SELECT sum(f.localtax) as amount";
377 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
378 $sql .=
" WHERE f.paye = 1";
383 $result = $this->db->query($sql);
385 if ($this->db->num_rows($result)) {
386 $obj = $this->db->fetch_object($result);
388 $this->db->free($result);
391 $this->db->free($result);
395 print $this->db->lasterror();
411 $sql =
"SELECT sum(f.total_localtax) as total_localtax";
412 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
417 $result = $this->db->query($sql);
419 if ($this->db->num_rows($result)) {
420 $obj = $this->db->fetch_object($result);
421 $ret = $obj->total_localtax;
422 $this->db->free($result);
425 $this->db->free($result);
429 print $this->db->lasterror();
446 $sql =
"SELECT sum(f.amount) as amount";
447 $sql .=
" FROM ".MAIN_DB_PREFIX.
"localtax as f";
452 $result = $this->db->query($sql);
454 if ($this->db->num_rows($result)) {
455 $obj = $this->db->fetch_object($result);
457 $this->db->free($result);
460 $this->db->free($result);
464 print $this->db->lasterror();
478 global $conf, $langs;
483 $this->amount =
price2num($this->amount);
485 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
488 if ($this->amount <= 0) {
489 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
492 if (isModEnabled(
"bank") && (empty($this->accountid) || $this->accountid <= 0)) {
493 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"BankAccount"));
496 if (isModEnabled(
"bank") && (empty($this->paymenttype) || $this->paymenttype <= 0)) {
497 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
502 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"localtax (localtaxtype, datep, datev, amount";
509 $sql .=
", fk_user_creat, fk_bank";
511 $sql .=
" VALUES (".$this->ltt.
", '".$this->db->idate($this->datep).
"',";
512 $sql .=
"'".$this->db->idate($this->datev).
"',".$this->amount;
514 $sql .=
", '".$this->db->escape($this->note).
"'";
517 $sql .=
", '".$this->db->escape($this->label).
"'";
519 $sql .=
", ".((int) $user->id).
", NULL";
522 dol_syslog(get_class($this).
"::addPayment", LOG_DEBUG);
523 $result = $this->db->query($sql);
525 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"localtax");
528 if (isModEnabled(
"bank")) {
530 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
533 $result = $acc->fetch($this->accountid);
538 $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs((
float) $this->amount),
'',
'', $user);
541 if ($bank_line_id > 0) {
544 $this->error = $acc->error;
549 $result = $acc->add_url_line($bank_line_id, $this->
id, DOL_URL_ROOT.
'/compta/localtax/card.php?id=',
"(VATPayment)",
"payment_vat");
551 $this->error = $acc->error;
560 $this->db->rollback();
564 $this->error = $this->db->lasterror();
565 $this->db->rollback();
569 $this->error = $this->db->lasterror();
570 $this->db->rollback();
585 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'localtax SET fk_bank = '.((int) $id);
586 $sql .=
' WHERE rowid = '.((int) $this->
id);
587 $result = $this->db->query($sql);
609 $label = $langs->trans(
"ShowVatPayment").
': '.$this->ref;
611 $link =
'<a href="'.DOL_URL_ROOT.
'/compta/localtax/card.php?id='.$this->
id.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
617 $result .= ($link.img_object($label, $picto,
'class="classfortooltip"').$linkend);
619 if ($withpicto && $withpicto != 2) {
622 if ($withpicto != 2) {
623 $result .= $link.$this->ref.$linkend;
666 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
668 $return =
'<div class="box-flex-item box-flex-grow-zero">';
669 $return .=
'<div class="info-box info-box-sm">';
670 $return .=
'<span class="info-box-icon bg-infobox-action">';
672 $return .=
'</span>';
673 $return .=
'<div class="info-box-content">';
674 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
675 if ($selected >= 0) {
676 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
678 if (property_exists($this,
'label')) {
679 $return .=
' | <span class="info-box-label">'.$this->label.
'</span>';
681 if (property_exists($this,
'datev')) {
682 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"DateEnd").
'</span> : <span class="info-box-label">'.
dol_print_date($this->db->jdate($this->datev),
'day').
'</span>';
684 if (property_exists($this,
'datep')) {
685 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"DatePayment",
'',
'',
'',
'', 5).
'</span> : <span class="info-box-label">'.
dol_print_date($this->db->jdate($this->datep),
'day').
'</span>';
687 if (property_exists($this,
'amount')) {
688 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Amount").
'</span> : <span class="info-box-label amount">'.
price($this->amount).
'</span>';
Class to manage bank accounts.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage local tax.
fetch($id)
Load object in memory from database.
LibStatut($status, $mode=0)
Return the label of a given status.
addPayment($user)
Add a payment of localtax.
solde($year=0)
Hum la function s'appelle 'Solde' elle doit a mon avis calcluer le solde de localtax,...
localtax_sum_payee($year=0)
Total of localtax paid in invoice.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
initAsSpecimen()
Initialise an instance with random values.
getNomUrl($withpicto=0, $option='')
Returns clickable name.
update(User $user, $notrigger=0)
Update database.
__construct($db)
Constructor.
getLibStatut($mode=0)
Return the label of the status.
update_fk_bank($id)
Update the link between localtax payment and the line into llx_bank.
create($user)
Create in database.
localtax_sum_collectee($year=0)
Total de la localtax des factures emises par la societe.
localtax_sum_reglee($year=0)
Total of localtax paid.
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut