dolibarr  7.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@capnetworks.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 {
34  var $id;
35  var $db;
36 
37  var $statuts = array();
38 
39 
46  function __construct($db, $user)
47  {
48  global $conf,$langs;
49 
50  $this->db = $db;
51  $this->user = $user;
52 
53  // List of language codes for status
54 
55  $langs->load("withdrawals");
56  $this->statuts[0]=$langs->trans("StatusWaiting");
57  $this->statuts[2]=$langs->trans("StatusCredited");
58  $this->statuts[3]=$langs->trans("StatusRefused");
59  }
60 
67  function fetch($rowid)
68  {
69  global $conf;
70 
71  $result = 0;
72 
73  $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid";
74  $sql.= ", pl.statut, pl.fk_soc";
75  $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
76  $sql.= ", ".MAIN_DB_PREFIX."prelevement_bons as p";
77  $sql.= " WHERE pl.rowid=".$rowid;
78  $sql.= " AND p.rowid = pl.fk_prelevement_bons";
79  $sql.= " AND p.entity = ".$conf->entity;
80 
81  $resql=$this->db->query($sql);
82  if ($resql)
83  {
84  if ($this->db->num_rows($resql))
85  {
86  $obj = $this->db->fetch_object($resql);
87 
88  $this->id = $obj->rowid;
89  $this->amount = $obj->amount;
90  $this->socid = $obj->fk_soc;
91  $this->statut = $obj->statut;
92  $this->bon_ref = $obj->ref;
93  $this->bon_rowid = $obj->bon_rowid;
94  }
95  else
96  {
97  $result++;
98  dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0");
99  }
100 
101  $this->db->free($resql);
102  }
103  else
104  {
105  $result++;
106  dol_syslog("LignePrelevement::Fetch rowid=$rowid");
107  dol_syslog($this->db->error());
108  }
109 
110  return $result;
111  }
112 
119  function getLibStatut($mode=0)
120  {
121  return $this->LibStatut($this->statut,$mode);
122  }
123 
131  function LibStatut($statut,$mode=0)
132  {
133  global $langs;
134 
135  if ($mode == 0)
136  {
137  return $langs->trans($this->statuts[$statut]);
138  }
139  if ($mode == 1)
140  {
141  if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]); // Waiting
142  if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited
143  if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused
144  }
145  if ($mode == 2)
146  {
147  if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
148  if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6');
149  if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8');
150  }
151  if ($mode == 3)
152  {
153  if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
154  if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6');
155  if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut8');
156  }
157  }
158 
167  public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
168  {
169  $tables = array(
170  'prelevement_lignes'
171  );
172 
173  return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
174  }
175 }
176 
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
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'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:105
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:1013
Class to manage withdrawals.