dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
19  *
20  */
21 
33 {
37  public $id;
38 
42  public $db;
43 
44  var $statuts = array();
45 
46 
53  function __construct($db, $user)
54  {
55  global $conf,$langs;
56 
57  $this->db = $db;
58  $this->user = $user;
59 
60  // List of language codes for status
61 
62  $langs->load("withdrawals");
63  $this->statuts[0]=$langs->trans("StatusWaiting");
64  $this->statuts[2]=$langs->trans("StatusCredited");
65  $this->statuts[3]=$langs->trans("StatusRefused");
66  }
67 
74  function fetch($rowid)
75  {
76  global $conf;
77 
78  $result = 0;
79 
80  $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid";
81  $sql.= ", pl.statut, pl.fk_soc";
82  $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
83  $sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as p";
84  $sql.= " WHERE pl.rowid=".$rowid;
85  $sql.= " AND p.rowid = pl.fk_prelevement_bons";
86  $sql.= " AND p.entity = ".$conf->entity;
87 
88  $resql=$this->db->query($sql);
89  if ($resql)
90  {
91  if ($this->db->num_rows($resql))
92  {
93  $obj = $this->db->fetch_object($resql);
94 
95  $this->id = $obj->rowid;
96  $this->amount = $obj->amount;
97  $this->socid = $obj->fk_soc;
98  $this->statut = $obj->statut;
99  $this->bon_ref = $obj->ref;
100  $this->bon_rowid = $obj->bon_rowid;
101  }
102  else
103  {
104  $result++;
105  dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0");
106  }
107 
108  $this->db->free($resql);
109  }
110  else
111  {
112  $result++;
113  dol_syslog("LignePrelevement::Fetch rowid=$rowid");
114  dol_syslog($this->db->error());
115  }
116 
117  return $result;
118  }
119 
126  function getLibStatut($mode=0)
127  {
128  return $this->LibStatut($this->statut,$mode);
129  }
130 
131  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
139  function LibStatut($statut,$mode=0)
140  {
141  // phpcs:enable
142  global $langs;
143 
144  if ($mode == 0)
145  {
146  return $langs->trans($this->statuts[$statut]);
147  }
148  elseif ($mode == 1)
149  {
150  if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]); // Waiting
151  if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited
152  if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused
153  }
154  elseif ($mode == 2)
155  {
156  if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
157  if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6');
158  if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8');
159  }
160  elseif ($mode == 3)
161  {
162  if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
163  if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6');
164  if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut8');
165  }
166  }
167 
176  public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
177  {
178  $tables = array(
179  'prelevement_lignes'
180  );
181 
182  return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
183  }
184 }
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
static replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
Class to manage Dolibarr database access.
LibStatut($statut, $mode=0)
Return status label for a status.
fetch($rowid)
Recupere l&#39;objet prelevement.
__construct($db, $user)
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
getLibStatut($mode=0)
Return status label of object.
static commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
$conf db user
Definition: repair.php:104
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
Class to manage withdrawals.