dolibarr 25.0.0-alpha
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 $picto = 'generic';
44
48 public $amount;
49
53 public $socid;
54
59 public $statut;
60
64 public $status;
65
69 public $bon_ref;
70
74 public $bon_rowid;
75
79 public $db;
80
84 public $labelStatus = array();
85
86 const STATUS_DRAFT = 0;
87 const STATUS_NOT_USED = 1;
88 const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
89 const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
90 const STATUS_REJECTED = 3;
91
92
98 public function __construct($db)
99 {
100 global $langs;
101
102 $this->db = $db;
103
104 // List of language codes for status
105
106 $langs->load("withdrawals");
107 $this->labelStatus[0] = $langs->trans("StatusWaiting");
108 $this->labelStatus[2] = $langs->trans("StatusPaid");
109 $this->labelStatus[3] = $langs->trans("StatusRefused");
110 }
111
118 public function fetch($rowid)
119 {
120 global $conf;
121
122 $error = 0;
123
124 $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid";
125 $sql .= ", pl.statut as status, pl.fk_soc";
126 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
127 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as p";
128 $sql .= " WHERE pl.rowid=".((int) $rowid);
129 $sql .= " AND p.rowid = pl.fk_prelevement_bons";
130 $sql .= " AND p.entity = ".((int) $conf->entity);
131
132 $resql = $this->db->query($sql);
133 if ($resql) {
134 if ($this->db->num_rows($resql)) {
135 $obj = $this->db->fetch_object($resql);
136
137 $this->id = $obj->rowid;
138 $this->amount = $obj->amount;
139 $this->socid = $obj->fk_soc;
140 $this->statut = $obj->status;
141 $this->status = $obj->status;
142 $this->bon_ref = $obj->ref;
143 $this->bon_rowid = $obj->bon_rowid;
144 } else {
145 $error++;
146 dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0");
147 }
148
149 $this->db->free($resql);
150 } else {
151 $error++;
152 dol_syslog("LignePrelevement::Fetch rowid=$rowid");
153 dol_syslog($this->db->error());
154 }
155
156 return $error;
157 }
158
165 public function getLibStatut($mode = 0)
166 {
167 return $this->LibStatut(isset($this->statut) ? $this->statut : $this->status, $mode);
168 }
169
170 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
178 public function LibStatut($status, $mode = 0)
179 {
180 // phpcs:enable
181 global $langs;
182
183 if ($mode == 0) {
184 return $langs->trans($this->labelStatus[$status]);
185 } elseif ($mode == 1) {
186 if ($status == 0) {
187 return img_picto($langs->trans($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Waiting
188 } elseif ($status == 2) {
189 return img_picto($langs->trans($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Credited
190 } elseif ($status == 3) {
191 return img_picto($langs->trans($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Refused
192 }
193 } elseif ($mode == 2) {
194 if ($status == 0) {
195 return img_picto($langs->trans($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"');
196 } elseif ($status == 2) {
197 return img_picto($langs->trans($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"');
198 } elseif ($status == 3) {
199 return img_picto($langs->trans($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"');
200 }
201 } elseif ($mode == 3) {
202 if ($status == 0) {
203 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"');
204 } elseif ($status == 2) {
205 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"');
206 } elseif ($status == 3) {
207 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"');
208 }
209 }
210 // return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
211 return null;
212 }
213
221 public function getKanbanView($option = '', $arraydata = null)
222 {
223 global $langs;
224
225 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
226
227 $return = '<div class="box-flex-item box-flex-grow-zero">';
228 $return .= '<div class="info-box info-box-sm">';
229 $return .= '<span class="info-box-icon bg-infobox-action">';
230 $return .= img_picto('', $this->picto);
231 $return .= '</span>';
232 $return .= '<div class="info-box-content">';
233 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . $this->id . '</span>';
234 if ($selected >= 0) {
235 $return .= '<input id="cb' . $this->id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
236 }
237 /*
238 if (isset($this->date_trans)) {
239 $return .= '<br><span class="opacitymedium">' . $langs->trans("TransData") . '</span> : <span class="info-box-label">' . dol_print_date($this->db->jdate($this->date_tans), 'day') . '</span>';
240 }
241 if (isset($this->date_credit)) {
242 $return .= '<br><span class="opacitymedium">' . $langs->trans("CreditDate") . '</span> : <span class="info-box-label">' . dol_print_date($this->db->jdate($this->date_credit), 'day') . '</span>';
243 }
244 if (isset($this->date_echeance)) {
245 $return .= '<br><span class="opacitymedium">' . $langs->trans("Date") . '</span> : <span class="info-box-label">' . dol_print_date($this->db->jdate($this->date_echeance), 'day') . '</span>';
246 }
247 */
248 if (isset($this->amount)) {
249 $return .= '<br><span class="opacitymedium">' . $langs->trans("Amount") . '</span> : <span class="amount">' . price($this->amount) . '</span>';
250 }
251 $return .= '<br><div class="info-box-status">' . $this->getLibStatut(3) . '</div>';
252 $return .= '</div>';
253 $return .= '</div>';
254 $return .= '</div>';
255 return $return;
256 }
257
266 public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
267 {
268 $tables = array(
269 'prelevement_lignes'
270 );
271
272 return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
273 }
274}
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.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
LibStatut($status, $mode=0)
Return status label for a status.
getLibStatut($mode=0)
Return status label of object.
__construct($db)
Constructor.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:169
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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_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)
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