23 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
34 public $element =
'localtax';
39 public $table_element =
'localtax';
44 public $picto =
'payment';
65 public $fk_user_creat;
70 public $fk_user_modif;
96 $this->amount = trim($this->amount);
97 $this->label = trim($this->label);
101 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"localtax(";
102 $sql .=
"localtaxtype,";
110 $sql .=
"fk_user_creat,";
111 $sql .=
"fk_user_modif";
112 $sql .=
") VALUES (";
113 $sql .=
" ".$this->ltt.
",";
114 $sql .=
" '".$this->db->idate($this->tms).
"',";
115 $sql .=
" '".$this->db->idate($this->datep).
"',";
116 $sql .=
" '".$this->db->idate($this->datev).
"',";
117 $sql .=
" '".$this->db->escape($this->amount).
"',";
118 $sql .=
" '".$this->db->escape($this->label).
"',";
119 $sql .=
" '".$this->db->escape($this->
note).
"',";
120 $sql .=
" ".($this->fk_bank <= 0 ?
"NULL" : (int) $this->fk_bank).
",";
121 $sql .=
" ".((int) $this->fk_user_creat).
",";
122 $sql .=
" ".((int) $this->fk_user_modif);
125 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
129 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"localtax");
132 $result = $this->
call_trigger(
'LOCALTAX_CREATE', $user);
133 if ($result < 0) $error++;
141 $this->
db->rollback();
145 $this->error =
"Error ".$this->db->lasterror();
146 $this->
db->rollback();
160 global $conf, $langs;
165 $this->amount = trim($this->amount);
166 $this->label = trim($this->label);
172 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"localtax SET";
173 $sql .=
" localtaxtype=".$this->ltt.
",";
174 $sql .=
" tms='".$this->db->idate($this->tms).
"',";
175 $sql .=
" datep='".$this->db->idate($this->datep).
"',";
176 $sql .=
" datev='".$this->db->idate($this->datev).
"',";
177 $sql .=
" amount=".price2num($this->amount).
",";
178 $sql .=
" label='".$this->db->escape($this->label).
"',";
179 $sql .=
" note='".$this->db->escape($this->
note).
"',";
180 $sql .=
" fk_bank=".(int) $this->fk_bank.
",";
181 $sql .=
" fk_user_creat=".(int) $this->fk_user_creat.
",";
182 $sql .=
" fk_user_modif=".(int) $this->fk_user_modif;
183 $sql .=
" WHERE rowid=".$this->id;
185 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
189 $this->error =
"Error ".$this->db->lasterror();
193 if (!$error && !$notrigger)
196 $result = $this->
call_trigger(
'LOCALTAX_MODIFY', $user);
197 if ($result < 0) $error++;
206 $this->
db->rollback();
223 $sql .=
" t.localtaxtype,";
227 $sql .=
" t.amount,";
230 $sql .=
" t.fk_bank,";
231 $sql .=
" t.fk_user_creat,";
232 $sql .=
" t.fk_user_modif,";
233 $sql .=
" b.fk_account,";
234 $sql .=
" b.fk_type,";
236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"localtax as t";
237 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON t.fk_bank = b.rowid";
238 $sql .=
" WHERE t.rowid = ".$id;
240 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
246 $obj = $this->
db->fetch_object(
$resql);
248 $this->
id = $obj->rowid;
249 $this->ref = $obj->rowid;
250 $this->ltt = $obj->localtaxtype;
251 $this->tms = $this->
db->jdate($obj->tms);
252 $this->datep = $this->
db->jdate($obj->datep);
253 $this->datev = $this->
db->jdate($obj->datev);
254 $this->amount = $obj->amount;
255 $this->label = $obj->label;
256 $this->
note = $obj->note;
257 $this->fk_bank = $obj->fk_bank;
258 $this->fk_user_creat = $obj->fk_user_creat;
259 $this->fk_user_modif = $obj->fk_user_modif;
260 $this->fk_account = $obj->fk_account;
261 $this->fk_type = $obj->fk_type;
262 $this->rappro = $obj->rappro;
268 $this->error =
"Error ".$this->db->lasterror();
280 public function delete($user)
283 $result = $this->
call_trigger(
'LOCALTAX_DELETE', $user);
284 if ($result < 0)
return -1;
287 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"localtax";
288 $sql .=
" WHERE rowid=".$this->id;
290 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
294 $this->error =
"Error ".$this->db->lasterror();
323 $this->fk_user_creat = $user->id;
324 $this->fk_user_modif = $user->id;
341 $solde = $reglee - ($collectee - $payee);
356 $sql =
"SELECT sum(f.localtax) as amount";
357 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f WHERE f.paye = 1";
360 $sql .=
" AND f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
363 $result = $this->
db->query($sql);
366 if ($this->
db->num_rows($result))
368 $obj = $this->
db->fetch_object($result);
370 $this->
db->free($result);
373 $this->
db->free($result);
393 $sql =
"SELECT sum(f.total_localtax) as total_localtax";
394 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
397 $sql .=
" WHERE f.datef >= '$year-01-01' AND f.datef <= '$year-12-31' ";
400 $result = $this->
db->query($sql);
403 if ($this->
db->num_rows($result))
405 $obj = $this->
db->fetch_object($result);
406 $ret = $obj->total_localtax;
407 $this->
db->free($result);
410 $this->
db->free($result);
431 $sql =
"SELECT sum(f.amount) as amount";
432 $sql .=
" FROM ".MAIN_DB_PREFIX.
"localtax as f";
435 $sql .=
" WHERE f.datev >= '$year-01-01' AND f.datev <= '$year-12-31' ";
438 $result = $this->
db->query($sql);
441 if ($this->
db->num_rows($result))
443 $obj = $this->
db->fetch_object($result);
445 $this->
db->free($result);
448 $this->
db->free($result);
466 global $conf, $langs;
471 $this->amount =
price2num($this->amount);
474 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
477 if ($this->amount <= 0)
479 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
482 if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
484 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Account"));
487 if (!empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0))
489 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
494 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"localtax (localtaxtype, datep, datev, amount";
495 if ($this->
note) $sql .=
", note";
496 if ($this->label) $sql .=
", label";
497 $sql .=
", fk_user_creat, fk_bank";
499 $sql .=
" VALUES (".$this->ltt.
", '".$this->
db->idate($this->datep).
"',";
500 $sql .=
"'".$this->db->idate($this->datev).
"',".$this->amount;
501 if ($this->
note) $sql .=
", '".$this->db->escape($this->
note).
"'";
502 if ($this->label) $sql .=
", '".$this->db->escape($this->label).
"'";
503 $sql .=
", ".((int) $user->id).
", NULL";
506 dol_syslog(get_class($this).
"::addPayment", LOG_DEBUG);
507 $result = $this->
db->query($sql);
510 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"localtax");
514 if (!empty($conf->banque->enabled))
517 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
520 $result = $acc->fetch($this->accountid);
523 $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount),
'',
'', $user);
526 if ($bank_line_id > 0)
530 $this->error = $acc->error;
535 $result = $acc->add_url_line($bank_line_id, $this->
id, DOL_URL_ROOT.
'/compta/localtax/card.php?id=',
"(VATPayment)",
"payment_vat");
538 $this->error = $acc->error;
548 $this->
db->rollback();
552 $this->error = $this->
db->lasterror();
553 $this->
db->rollback();
557 $this->error = $this->
db->lasterror();
558 $this->
db->rollback();
573 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'localtax SET fk_bank = '.$id;
574 $sql .=
' WHERE rowid = '.$this->id;
575 $result = $this->
db->query($sql);
597 $label = $langs->trans(
"ShowVatPayment").
': '.$this->ref;
599 $link =
'<a href="'.DOL_URL_ROOT.
'/compta/localtax/card.php?id='.$this->
id.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
604 if ($withpicto) $result .= ($link.img_object($label, $picto,
'class="classfortooltip"').$linkend);
605 if ($withpicto && $withpicto != 2) $result .=
' ';
606 if ($withpicto != 2) $result .= $link.$this->ref.$linkend;
__construct($db)
Constructor.
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
update(User $user, $notrigger=0)
Update database.
update_fk_bank($id)
Update the link betwen localtax payment and the line into llx_bank.
Class to manage Dolibarr users.
initAsSpecimen()
Initialise an instance with random values.
localtax_sum_reglee($year=0)
Total of localtax paid.
$conf db
API class for accounts.
Class to manage bank accounts.
fetch($id)
Load object in memory from database.
localtax_sum_collectee($year=0)
Total de la localtax des factures emises par la societe.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
localtax_sum_payee($year=0)
Total of localtax paid in invoice.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
create($user)
Create in database.
addPayment($user)
Add a payment of localtax.
print
Draft customers invoices.
call_trigger($triggerName, $user)
Call trigger based on this instance.
LibStatut($status, $mode=0)
Renvoi le libelle d'un statut donne.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
solde($year=0)
Hum la fonction s'appelle 'Solde' elle doit a mon avis calcluer le solde de localtax, non ?
Class to manage local tax.
getLibStatut($mode=0)
Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) ...
getNomUrl($withpicto=0, $option= '')
Returns clickable name.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
if(!empty($search_group)) natural_search(array("g.nom"g note
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...