dolibarr  16.0.5
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 $db;
43 
44  public $statuts = array();
45 
46 
52  public function __construct($db)
53  {
54  global $conf, $langs;
55 
56  $this->db = $db;
57 
58  // List of language codes for status
59 
60  $langs->load("withdrawals");
61  $this->statuts[0] = $langs->trans("StatusWaiting");
62  $this->statuts[2] = $langs->trans("StatusPaid");
63  $this->statuts[3] = $langs->trans("StatusRefused");
64  }
65 
72  public function fetch($rowid)
73  {
74  global $conf;
75 
76  $error = 0;
77 
78  $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid";
79  $sql .= ", pl.statut, pl.fk_soc";
80  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
81  $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as p";
82  $sql .= " WHERE pl.rowid=".((int) $rowid);
83  $sql .= " AND p.rowid = pl.fk_prelevement_bons";
84  $sql .= " AND p.entity = ".$conf->entity;
85 
86  $resql = $this->db->query($sql);
87  if ($resql) {
88  if ($this->db->num_rows($resql)) {
89  $obj = $this->db->fetch_object($resql);
90 
91  $this->id = $obj->rowid;
92  $this->amount = $obj->amount;
93  $this->socid = $obj->fk_soc;
94  $this->statut = $obj->statut;
95  $this->bon_ref = $obj->ref;
96  $this->bon_rowid = $obj->bon_rowid;
97  } else {
98  $error++;
99  dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0");
100  }
101 
102  $this->db->free($resql);
103  } else {
104  $error++;
105  dol_syslog("LignePrelevement::Fetch rowid=$rowid");
106  dol_syslog($this->db->error());
107  }
108 
109  return $error;
110  }
111 
118  public function getLibStatut($mode = 0)
119  {
120  return $this->LibStatut($this->statut, $mode);
121  }
122 
123  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
131  public function LibStatut($status, $mode = 0)
132  {
133  // phpcs:enable
134  global $langs;
135 
136  if ($mode == 0) {
137  return $langs->trans($this->statuts[$status]);
138  } elseif ($mode == 1) {
139  if ($status == 0) {
140  return img_picto($langs->trans($this->statuts[$status]), 'statut1', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->statuts[$status]); // Waiting
141  } elseif ($status == 2) {
142  return img_picto($langs->trans($this->statuts[$status]), 'statut6', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->statuts[$status]); // Credited
143  } elseif ($status == 3) {
144  return img_picto($langs->trans($this->statuts[$status]), 'statut8', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->statuts[$status]); // Refused
145  }
146  } elseif ($mode == 2) {
147  if ($status == 0) {
148  return img_picto($langs->trans($this->statuts[$status]), 'statut1', 'class="valignmiddle"');
149  } elseif ($status == 2) {
150  return img_picto($langs->trans($this->statuts[$status]), 'statut6', 'class="valignmiddle"');
151  } elseif ($status == 3) {
152  return img_picto($langs->trans($this->statuts[$status]), 'statut8', 'class="valignmiddle"');
153  }
154  } elseif ($mode == 3) {
155  if ($status == 0) {
156  return $langs->trans($this->statuts[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->statuts[$status]), 'statut1', 'class="valignmiddle"');
157  } elseif ($status == 2) {
158  return $langs->trans($this->statuts[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->statuts[$status]), 'statut6', 'class="valignmiddle"');
159  } elseif ($status == 3) {
160  return $langs->trans($this->statuts[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->statuts[$status]), 'statut8', 'class="valignmiddle"');
161  }
162  }
163 
164  //return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
165  }
166 
175  public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
176  {
177  $tables = array(
178  'prelevement_lignes'
179  );
180 
181  return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
182  }
183 }
db
$conf db
API class for accounts.
Definition: inc.php:41
LignePrelevement
Class to manage withdrawals.
Definition: ligneprelevement.class.php:32
DoliDB
Class to manage Dolibarr database access.
Definition: DoliDB.class.php:30
LignePrelevement\__construct
__construct($db)
Constructor.
Definition: ligneprelevement.class.php:52
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
LignePrelevement\replaceThirdparty
static replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
Definition: ligneprelevement.class.php:175
LignePrelevement\LibStatut
LibStatut($status, $mode=0)
Return status label for a status.
Definition: ligneprelevement.class.php:131
LignePrelevement\getLibStatut
getLibStatut($mode=0)
Return status label of object.
Definition: ligneprelevement.class.php:118
CommonObject\commonReplaceThirdparty
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
Definition: commonobject.class.php:8347
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
LignePrelevement\fetch
fetch($rowid)
Recupere l'objet prelevement.
Definition: ligneprelevement.class.php:72