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);
664 return $this->
LibStatut($this->statut, $mode);
712 public function getNomUrl($withpicto = 0, $option =
'', $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'')
714 global $db,
$conf, $langs, $hookmanager;
717 if (!empty(
$conf->dol_no_mouse_hover)) {
723 $label =
'<u>'.$langs->trans(
"ShowVariousPayment").
'</u>';
725 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
727 $url = DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.$this->id;
729 if ($option !=
'nolink') {
731 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
732 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
733 $add_save_lastsearch_values = 1;
735 if ($add_save_lastsearch_values) {
736 $url .=
'&save_lastsearch_values=1';
741 if (empty($notooltip)) {
743 $label = $langs->trans(
"ShowMyObject");
744 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
746 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
747 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
749 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
752 $linkstart =
'<a href="'.$url.
'"';
753 $linkstart .= $linkclose.
'>';
756 $result .= $linkstart;
758 $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);
760 if ($withpicto != 2) {
761 $result .= $this->ref;
767 $hookmanager->initHooks(array(
'variouspayment'));
768 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
769 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
771 $result = $hookmanager->resPrint;
773 $result .= $hookmanager->resPrint;
787 $sql =
'SELECT v.rowid, v.datec, v.fk_user_author, fk_user_modif, tms';
788 $sql .=
' FROM '.MAIN_DB_PREFIX.
'payment_various as v';
789 $sql .=
' WHERE v.rowid = '.((int) $id);
791 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
792 $result = $this->db->query($sql);
795 if ($this->db->num_rows($result)) {
796 $obj = $this->db->fetch_object($result);
798 $this->
id = $obj->rowid;
799 $this->user_creation = $obj->fk_user_author;
800 $this->user_creation_id = $obj->fk_user_author;
801 $this->user_modification_id = $obj->fk_user_modif;
802 $this->date_creation = $this->db->jdate($obj->datec);
803 $this->date_modification = $this->db->jdate($obj->tms);
805 $this->db->free($result);
819 $banklineid = $this->fk_bank;
821 $alreadydispatched = 0;
825 $sql =
" SELECT ".($mode ?
'DISTINCT piece_num' :
'COUNT(ab.rowid)').
" as nb";
826 $sql .=
" FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type = '".$this->db->escape($type).
"' AND ab.fk_doc = ".((int) $banklineid);
827 $resql = $this->db->query($sql);
829 $obj = $this->db->fetch_object($resql);
831 $alreadydispatched = $obj->nb;
834 $this->error = $this->db->lasterror();
838 if ($alreadydispatched) {
839 return $alreadydispatched;
855 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
856 $bankline = ((empty($arraydata[
'bankline']) || empty($arraydata[
'bankline']->
id)) ? 0 : $arraydata[
'bankline']);
857 $formatedaccountancycode = (empty($arraydata[
'formatedaccountancycode']) ?
'' : $arraydata[
'formatedaccountancycode']);
859 $return =
'<div class="box-flex-item box-flex-grow-zero">';
860 $return .=
'<div class="info-box info-box-sm">';
861 $return .=
'<span class="info-box-icon bg-infobox-action">';
863 $return .=
'</span>';
864 $return .=
'<div class="info-box-content">';
865 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1) : $this->ref).
'</span>';
866 if ($selected >= 0) {
867 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
869 if (!empty($bankline) && $bankline instanceof
AccountLine) {
870 $return .=
' | <span class="info-box-status ">'.$bankline->getNomUrl(1).
'</span>';
872 if (property_exists($this,
'datep')) {
873 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Date").
'</span> : <span class="info-box-label">'.
dol_print_date($this->datep,
'day').
'</span>';
874 if ($this->type_payment) {
875 $return .=
' - <span class="info-box-label">'.$this->type_payment.
'</span>';
878 if (!empty($formatedaccountancycode)) {
879 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Account").
'</span> : <span class="info-box-label" title="'.$this->accountancy_code.
'">';
880 $return .= $formatedaccountancycode;
881 $return .=
'</span>';
882 } elseif (property_exists($this,
'accountancy_code')) {
883 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Account").
'</span> : <span class="info-box-label" title="'.$this->accountancy_code.
'">'.$this->accountancy_code.
'</span>';
886 if (property_exists($this,
'amount')) {
887 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Debit").
'</span> : <span class="info-box-label amount">'.
price($this->
amount).
'</span>';
903 include_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
922 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.
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.
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_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).
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.
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)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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
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