dolibarr 19.0.3
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 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 *
20 */
21
33{
37 public $id;
38
42 public $amount;
43
47 public $socid;
48
52 public $statut;
53
57 public $bon_ref;
58
62 public $bon_rowid;
63
67 public $db;
68
69 public $labelStatus = array();
70
71 const STATUS_DRAFT = 0;
72 const STATUS_NOT_USED = 1;
73 const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
74 const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
75 const STATUS_REJECTED = 3;
76
77
83 public function __construct($db)
84 {
85 global $conf, $langs;
86
87 $this->db = $db;
88
89 // List of language codes for status
90
91 $langs->load("withdrawals");
92 $this->labelStatus[0] = $langs->trans("StatusWaiting");
93 $this->labelStatus[2] = $langs->trans("StatusPaid");
94 $this->labelStatus[3] = $langs->trans("StatusRefused");
95 }
96
103 public function fetch($rowid)
104 {
105 global $conf;
106
107 $error = 0;
108
109 $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid";
110 $sql .= ", pl.statut, pl.fk_soc";
111 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
112 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as p";
113 $sql .= " WHERE pl.rowid=".((int) $rowid);
114 $sql .= " AND p.rowid = pl.fk_prelevement_bons";
115 $sql .= " AND p.entity = ".$conf->entity;
116
117 $resql = $this->db->query($sql);
118 if ($resql) {
119 if ($this->db->num_rows($resql)) {
120 $obj = $this->db->fetch_object($resql);
121
122 $this->id = $obj->rowid;
123 $this->amount = $obj->amount;
124 $this->socid = $obj->fk_soc;
125 $this->statut = $obj->statut;
126 $this->bon_ref = $obj->ref;
127 $this->bon_rowid = $obj->bon_rowid;
128 } else {
129 $error++;
130 dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0");
131 }
132
133 $this->db->free($resql);
134 } else {
135 $error++;
136 dol_syslog("LignePrelevement::Fetch rowid=$rowid");
137 dol_syslog($this->db->error());
138 }
139
140 return $error;
141 }
142
149 public function getLibStatut($mode = 0)
150 {
151 return $this->LibStatut($this->statut, $mode);
152 }
153
154 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
162 public function LibStatut($status, $mode = 0)
163 {
164 // phpcs:enable
165 global $langs;
166
167 if ($mode == 0) {
168 return $langs->trans($this->labelStatus[$status]);
169 } elseif ($mode == 1) {
170 if ($status == 0) {
171 return img_picto($langs->trans($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Waiting
172 } elseif ($status == 2) {
173 return img_picto($langs->trans($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Credited
174 } elseif ($status == 3) {
175 return img_picto($langs->trans($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->labelStatus[$status]); // Refused
176 }
177 } elseif ($mode == 2) {
178 if ($status == 0) {
179 return img_picto($langs->trans($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"');
180 } elseif ($status == 2) {
181 return img_picto($langs->trans($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"');
182 } elseif ($status == 3) {
183 return img_picto($langs->trans($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"');
184 }
185 } elseif ($mode == 3) {
186 if ($status == 0) {
187 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut1', 'class="valignmiddle"');
188 } elseif ($status == 2) {
189 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut6', 'class="valignmiddle"');
190 } elseif ($status == 3) {
191 return $langs->trans($this->labelStatus[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->labelStatus[$status]), 'statut8', 'class="valignmiddle"');
192 }
193 }
194 //return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
195 }
196
205 public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
206 {
207 $tables = array(
208 'prelevement_lignes'
209 );
210
211 return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
212 }
213}
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e e e e e statut
Definition invoice.php:1907