28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 public $element =
'payment_various';
44 public $table_element =
'payment_various';
49 public $picto =
'payment';
105 public $category_transaction;
115 public $accountancy_code;
120 public $subledger_account;
146 public $categorie_transaction;
151 public $fk_user_author;
156 public $fk_user_modif;
172 public $bank_num_releve;
204 public $fields = array(
232 public function update($user =
null, $notrigger = 0)
234 global
$conf, $langs;
240 $this->label = trim($this->label);
241 $this->note = trim($this->note);
242 $this->fk_bank = (int) $this->fk_bank;
243 $this->fk_user_author = (int) $this->fk_user_author;
244 $this->fk_user_modif = (int) $this->fk_user_modif;
249 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"payment_various SET";
251 $sql .=
" tms='".$this->db->idate($this->tms).
"',";
253 $sql .=
" datep='".$this->db->idate($this->datep).
"',";
254 $sql .=
" datev='".$this->db->idate($this->datev).
"',";
255 $sql .=
" sens=".(int) $this->sens.
",";
256 $sql .=
" amount=".price2num($this->
amount).
",";
257 $sql .=
" fk_typepayment=".(int) $this->type_payment.
",";
258 $sql .=
" num_payment='".$this->db->escape($this->num_payment).
"',";
259 $sql .=
" label='".$this->db->escape($this->label).
"',";
260 $sql .=
" note='".$this->db->escape($this->note).
"',";
261 $sql .=
" accountancy_code='".$this->db->escape($this->accountancy_code).
"',";
262 $sql .=
" subledger_account='".$this->db->escape($this->subledger_account).
"',";
263 $sql .=
" fk_projet='".$this->db->escape((
string) $this->fk_project).
"',";
264 $sql .=
" fk_bank=".($this->fk_bank > 0 ? ((int) $this->fk_bank) :
"null").
",";
265 $sql .=
" fk_user_author=".(int) $this->fk_user_author.
",";
266 $sql .=
" fk_user_modif=".(int) $this->fk_user_modif;
267 $sql .=
" WHERE rowid=".((int) $this->
id);
269 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
270 $resql = $this->db->query($sql);
272 $this->error =
"Error ".$this->db->lasterror();
282 if (!$error && !$notrigger) {
284 $result = $this->call_trigger(
'PAYMENT_VARIOUS_MODIFY', $user);
295 $this->db->rollback();
308 public function fetch($id, $user =
null)
316 $sql .=
" v.amount,";
317 $sql .=
" v.fk_typepayment,";
318 $sql .=
" v.num_payment,";
320 $sql .=
" v.note as note_private,";
321 $sql .=
" v.accountancy_code,";
322 $sql .=
" v.subledger_account,";
323 $sql .=
" v.fk_projet as fk_project,";
324 $sql .=
" v.fk_bank,";
325 $sql .=
" v.fk_user_author,";
326 $sql .=
" v.fk_user_modif,";
327 $sql .=
" b.fk_account,";
328 $sql .=
" b.fk_type,";
329 $sql .=
" b.rappro,";
330 $sql .=
" b.num_releve as bank_num_releve";
331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_various as v";
332 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank as b ON v.fk_bank = b.rowid";
333 $sql .=
" WHERE v.rowid = ".((int) $id);
335 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
336 $resql = $this->db->query($sql);
338 if ($this->db->num_rows($resql)) {
339 $obj = $this->db->fetch_object($resql);
341 $this->
id = $obj->rowid;
342 $this->
ref = $obj->rowid;
343 $this->tms = $this->db->jdate($obj->tms);
344 $this->datep = $this->db->jdate($obj->datep);
345 $this->datev = $this->db->jdate($obj->datev);
346 $this->sens = $obj->sens;
347 $this->
amount = $obj->amount;
348 $this->type_payment = $obj->fk_typepayment;
349 $this->num_payment = $obj->num_payment;
350 $this->label = $obj->label;
351 $this->note = $obj->note_private;
352 $this->note_private = $obj->note_private;
353 $this->subledger_account = $obj->subledger_account;
354 $this->accountancy_code = $obj->accountancy_code;
355 $this->fk_project = $obj->fk_project;
356 $this->fk_bank = $obj->fk_bank;
357 $this->fk_user_author = $obj->fk_user_author;
358 $this->fk_user_modif = $obj->fk_user_modif;
359 $this->fk_account = $obj->fk_account;
360 $this->fk_type = $obj->fk_type;
361 $this->rappro = $obj->rappro;
362 $this->bank_num_releve = $obj->bank_num_releve;
368 $this->db->free($resql);
372 $this->error =
"Error ".$this->db->lasterror();
384 public function delete($user)
386 global
$conf, $langs;
391 $result = $this->call_trigger(
'PAYMENT_VARIOUS_DELETE', $user);
398 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"payment_various";
399 $sql .=
" WHERE rowid=".((int) $this->
id);
401 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
402 $resql = $this->db->query($sql);
404 $this->error =
"Error ".$this->db->lasterror();
427 $this->label =
'Specimen payment';
428 $this->accountancy_code =
'';
429 $this->subledger_account =
'';
432 $this->fk_user_author = 0;
433 $this->fk_user_modif = 0;
448 if (!($newamount) > 0 || empty($this->datep)) {
463 global
$conf, $langs;
470 $this->label = trim($this->label);
471 $this->note = trim($this->note);
472 $this->fk_bank = (int) $this->fk_bank;
473 $this->fk_user_author = (int) $this->fk_user_author;
474 $this->fk_user_modif = (int) $this->fk_user_modif;
475 $this->fk_account = (int) $this->fk_account;
476 if (empty($this->fk_account) && isset($this->accountid)) {
477 $this->fk_account = $this->accountid;
482 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label"));
486 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Amount"));
489 if (
isModEnabled(
"bank") && (empty($this->fk_account) || $this->fk_account <= 0)) {
490 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"BankAccount"));
493 if (
isModEnabled(
"bank") && (empty($this->type_payment) || $this->type_payment <= 0)) {
494 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"PaymentMode"));
501 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"payment_various (";
506 $sql .=
", fk_typepayment";
507 $sql .=
", num_payment";
512 $sql .=
", accountancy_code";
513 $sql .=
", subledger_account";
514 $sql .=
", fk_projet";
515 $sql .=
", fk_user_author";
521 $sql .=
"'".$this->db->idate($this->datep).
"'";
522 $sql .=
", '".$this->db->idate($this->datev).
"'";
523 $sql .=
", '".$this->db->escape((
string) $this->sens).
"'";
524 $sql .=
", ".price2num($this->
amount);
525 $sql .=
", '".$this->db->escape((
string) $this->type_payment).
"'";
526 $sql .=
", '".$this->db->escape($this->num_payment).
"'";
528 $sql .=
", '".$this->db->escape($this->note).
"'";
530 $sql .=
", '".$this->db->escape($this->label).
"'";
531 $sql .=
", '".$this->db->escape($this->accountancy_code).
"'";
532 $sql .=
", '".$this->db->escape($this->subledger_account).
"'";
533 $sql .=
", ".($this->fk_project > 0 ? ((int) $this->fk_project) : 0);
534 $sql .=
", ".((int) $user->id);
535 $sql .=
", '".$this->db->idate($now).
"'";
537 $sql .=
", ".((int)
$conf->entity);
540 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
541 $result = $this->db->query($sql);
543 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"payment_various");
555 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
558 $result = $acc->fetch($this->fk_account);
566 if ($this->sens ==
'0') {
570 $bank_line_id = $acc->addline(
572 (
string) $this->type_payment,
574 $sign * abs($this->
amount),
576 ($this->category_transaction > 0 ? $this->category_transaction : 0),
586 if ($bank_line_id > 0) {
589 $this->error = $acc->error;
595 $url = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id=';
597 $result = $acc->add_url_line($bank_line_id, $this->
id, $url,
"(VariousPayment)",
"payment_various");
599 $this->error = $acc->error;
605 $this->error = $acc->error;
611 $result = $this->call_trigger(
'PAYMENT_VARIOUS_CREATE', $user);
624 $this->db->rollback();
628 $this->error = $this->db->error();
629 $this->db->rollback();
644 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'payment_various SET fk_bank = '.((int) $id_bank);
645 $sql .=
" WHERE rowid = ".((int) $this->
id);
646 $result = $this->db->query($sql);
650 $this->fk_bank = (int) $id_bank;
667 return $this->
LibStatut($this->statut, $mode);
715 public function getNomUrl($withpicto = 0, $option =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
717 global $db,
$conf, $langs, $hookmanager;
720 if (!empty(
$conf->dol_no_mouse_hover)) {
726 $label =
'<u>'.$langs->trans(
"ShowVariousPayment").
'</u>';
728 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
730 $url = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.$this->id;
732 if ($option !=
'nolink') {
734 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
735 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
736 $add_save_lastsearch_values = 1;
738 if ($add_save_lastsearch_values) {
739 $url .=
'&save_lastsearch_values=1';
744 if (empty($notooltip)) {
746 $label = $langs->trans(
"ShowMyObject");
747 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
749 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
750 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
752 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
755 $linkstart =
'<a href="'.$url.
'"';
756 $linkstart .= $linkclose.
'>';
759 $result .= $linkstart;
761 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
763 if ($withpicto != 2) {
764 $result .= $this->ref;
770 $hookmanager->initHooks(array(
'variouspayment'));
771 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
772 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
774 $result = $hookmanager->resPrint;
776 $result .= $hookmanager->resPrint;
790 $sql =
'SELECT v.rowid, v.datec, v.fk_user_author, fk_user_modif, tms';
791 $sql .=
' FROM '.MAIN_DB_PREFIX.
'payment_various as v';
792 $sql .=
' WHERE v.rowid = '.((int) $id);
794 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
795 $result = $this->db->query($sql);
798 if ($this->db->num_rows($result)) {
799 $obj = $this->db->fetch_object($result);
801 $this->
id = $obj->rowid;
802 $this->user_creation = $obj->fk_user_author;
803 $this->user_creation_id = $obj->fk_user_author;
804 $this->user_modification_id = $obj->fk_user_modif;
805 $this->date_creation = $this->db->jdate($obj->datec);
806 $this->date_modification = $this->db->jdate($obj->tms);
808 $this->db->free($result);
822 $banklineid = $this->fk_bank;
824 $alreadydispatched = 0;
828 $sql =
" SELECT ".($mode ?
'DISTINCT piece_num' :
'COUNT(ab.rowid)').
" as nb";
829 $sql .=
" FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type).
"' AND ab.fk_doc = ".((int) $banklineid);
830 $resql = $this->db->query($sql);
832 $obj = $this->db->fetch_object($resql);
834 $alreadydispatched = $obj->nb;
837 $this->error = $this->db->lasterror();
841 if ($alreadydispatched) {
842 return $alreadydispatched;
858 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
859 $bankline = ((empty($arraydata[
'bankline']) || empty($arraydata[
'bankline']->
id)) ? 0 : $arraydata[
'bankline']);
860 $formatedaccountancycode = (empty($arraydata[
'formatedaccountancycode']) ?
'' : $arraydata[
'formatedaccountancycode']);
862 $return =
'<div class="box-flex-item box-flex-grow-zero">';
863 $return .=
'<div class="info-box info-box-sm">';
864 $return .=
'<span class="info-box-icon bg-infobox-action">';
866 $return .=
'</span>';
867 $return .=
'<div class="info-box-content">';
868 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</span>';
869 if ($selected >= 0) {
870 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
872 if (!empty($bankline) && $bankline instanceof
AccountLine) {
873 $return .=
' | <span class="info-box-status ">'.$bankline->getNomUrl(1).
'</span>';
875 if (property_exists($this,
'datep')) {
876 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Date").
'</span> : <span class="info-box-label">'.
dol_print_date($this->datep,
'day').
'</span>';
877 if ($this->type_payment) {
878 $return .=
' - <span class="info-box-label">'.$this->type_payment.
'</span>';
881 if (!empty($formatedaccountancycode)) {
882 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Account").
'</span> : <span class="info-box-label" title="'.$this->accountancy_code.
'">';
883 $return .= $formatedaccountancycode;
884 $return .=
'</span>';
885 } elseif (property_exists($this,
'accountancy_code')) {
886 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Account").
'</span> : <span class="info-box-label" title="'.$this->accountancy_code.
'">'.$this->accountancy_code.
'</span>';
889 if (property_exists($this,
'amount')) {
890 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Debit").
'</span> : <span class="info-box-label amount">'.
price($this->
amount).
'</span>';
906 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
925 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
Class to manage bank accounts.
Class to manage bank transaction lines.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Class to manage Dolibarr database access.
Class to manage various payments.
update_fk_bank($id_bank)
Update link between payment various and line generate into llx_bank.
getNomUrl($withpicto=0, $option='', $save_lastsearch_value=-1, $notooltip=0, $morecss='')
Send name clickable (with possibly the picto)
initAsSpecimen()
Initialise an instance with random values.
getVentilExportCompta($mode=0)
Return if a various payment linked to a bank line id was dispatched into bookkeeping.
const STATUS_DRAFT
Draft status.
create($user)
Create in database.
lengthAccountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
LibStatut($status, $mode=0)
Return the label of a given status.
fetch($id, $user=null)
Load object in memory from database.
info($id)
Information on record.
lengthAccounta($account)
Return Auxiliary accounting account of thirdparties with defined length.
check()
Check if a miscellaneous payment can be created into database.
__construct(DoliDB $db)
Constructor.
getLibStatut($mode=0)
Return the label of the status.
update($user=null, $notrigger=0)
Update database.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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 '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount