dolibarr 24.0.0-beta
ligneprelevement.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
6 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 *
21 */
22
34{
38 public $id;
39
43 public $amount;
44
48 public $socid;
49
53 public $statut;
54
58 public $bon_ref;
59
63 public $bon_rowid;
64
68 public $db;
69
73 public $labelStatus = array();
74
75 const STATUS_DRAFT = 0;
76 const STATUS_NOT_USED = 1;
77 const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
78 const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
79 const STATUS_REJECTED = 3;
80
81
87 public function __construct($db)
88 {
89 global $conf, $langs;
90
91 $this->db = $db;
92
93 // List of language codes for status
94
95 $langs->load("withdrawals");
96 $this->labelStatus[0] = $langs->trans("StatusWaiting");
97 $this->labelStatus[2] = $langs->trans("StatusPaid");
98 $this->labelStatus[3] = $langs->trans("StatusRefused");
99 }
100
107 public function fetch($rowid)
108 {
109 global $conf;
110
111 $error = 0;
112
113 $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid";
114 $sql .= ", pl.statut, pl.fk_soc";
115 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
116 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as p";
117 $sql .= " WHERE pl.rowid=".((int) $rowid);
118 $sql .= " AND p.rowid = pl.fk_prelevement_bons";
119 $sql .= " AND p.entity = ".$conf->entity;
120
121 $resql = $this->db->query($sql);
122 if ($resql) {
123 if ($this->db->num_rows($resql)) {
124 $obj = $this->db->fetch_object($resql);
125
126 $this->id = $obj->rowid;
127 $this->amount = $obj->amount;
128 $this->socid = $obj->fk_soc;
129 $this->statut = $obj->statut;
130 $this->bon_ref = $obj->ref;
131 $this->bon_rowid = $obj->bon_rowid;
132 } else {
133 $error++;
134 dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0");
135 }
136
137 $this->db->free($resql);
138 } else {
139 $error++;
140 dol_syslog("LignePrelevement::Fetch rowid=$rowid");
141 dol_syslog($this->db->error());
142 }
143
144 return $error;
145 }
146
153 public function getLibStatut($mode = 0)
154 {
155 return $this->LibStatut($this->statut, $mode);
156 }
157
158 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
166 public function LibStatut($status, $mode = 0)
167 {
168 // phpcs:enable
169 global $langs;
170
171 if ($mode == 0) {
172 return $langs->trans($this->labelStatus[$status]);
173 } elseif ($mode == 1) {
174 if ($status == 0) {
175 return img_picto($langs->trans($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Waiting
176 } elseif ($status == 2) {
177 return img_picto($langs->trans($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Credited
178 } elseif ($status == 3) {
179 return img_picto($langs->trans($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Refused
180 }
181 } elseif ($mode == 2) {
182 if ($status == 0) {
183 return img_picto($langs->trans($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"');
184 } elseif ($status == 2) {
185 return img_picto($langs->trans($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"');
186 } elseif ($status == 3) {
187 return img_picto($langs->trans($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"');
188 }
189 } elseif ($mode == 3) {
190 if ($status == 0) {
191 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"');
192 } elseif ($status == 2) {
193 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"');
194 } elseif ($status == 3) {
195 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"');
196 }
197 }
198 // return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
199 return null;
200 }
201
210 public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
211 {
212 $tables = array(
213 'prelevement_lignes'
214 );
215
216 return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
217 }
218}
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
Class to manage Dolibarr database access.
Class to manage withdrawals.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
fetch($rowid)
Recupere l'objet prelevement.
LibStatut($status, $mode=0)
Return status label for a status.
getLibStatut($mode=0)
Return status label of object.
__construct($db)
Constructor.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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
Definition receipt.php:489