dolibarr  18.0.6
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  const STATUS_DRAFT = 0;
47  const STATUS_NOT_USED = 1;
48  const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
49  const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
50  const STATUS_REJECTED = 3;
51 
52 
58  public function __construct($db)
59  {
60  global $conf, $langs;
61 
62  $this->db = $db;
63 
64  // List of language codes for status
65 
66  $langs->load("withdrawals");
67  $this->statuts[0] = $langs->trans("StatusWaiting");
68  $this->statuts[2] = $langs->trans("StatusPaid");
69  $this->statuts[3] = $langs->trans("StatusRefused");
70  }
71 
78  public function fetch($rowid)
79  {
80  global $conf;
81 
82  $error = 0;
83 
84  $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid";
85  $sql .= ", pl.statut, pl.fk_soc";
86  $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
87  $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as p";
88  $sql .= " WHERE pl.rowid=".((int) $rowid);
89  $sql .= " AND p.rowid = pl.fk_prelevement_bons";
90  $sql .= " AND p.entity = ".$conf->entity;
91 
92  $resql = $this->db->query($sql);
93  if ($resql) {
94  if ($this->db->num_rows($resql)) {
95  $obj = $this->db->fetch_object($resql);
96 
97  $this->id = $obj->rowid;
98  $this->amount = $obj->amount;
99  $this->socid = $obj->fk_soc;
100  $this->statut = $obj->statut;
101  $this->bon_ref = $obj->ref;
102  $this->bon_rowid = $obj->bon_rowid;
103  } else {
104  $error++;
105  dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0");
106  }
107 
108  $this->db->free($resql);
109  } else {
110  $error++;
111  dol_syslog("LignePrelevement::Fetch rowid=$rowid");
112  dol_syslog($this->db->error());
113  }
114 
115  return $error;
116  }
117 
124  public function getLibStatut($mode = 0)
125  {
126  return $this->LibStatut($this->statut, $mode);
127  }
128 
129  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
137  public function LibStatut($status, $mode = 0)
138  {
139  // phpcs:enable
140  global $langs;
141 
142  if ($mode == 0) {
143  return $langs->trans($this->statuts[$status]);
144  } elseif ($mode == 1) {
145  if ($status == 0) {
146  return img_picto($langs->trans($this->statuts[$status]), 'statut1', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->statuts[$status]); // Waiting
147  } elseif ($status == 2) {
148  return img_picto($langs->trans($this->statuts[$status]), 'statut6', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->statuts[$status]); // Credited
149  } elseif ($status == 3) {
150  return img_picto($langs->trans($this->statuts[$status]), 'statut8', 'class="valignmiddle"').' '.$langs->transnoentitiesnoconv($this->statuts[$status]); // Refused
151  }
152  } elseif ($mode == 2) {
153  if ($status == 0) {
154  return img_picto($langs->trans($this->statuts[$status]), 'statut1', 'class="valignmiddle"');
155  } elseif ($status == 2) {
156  return img_picto($langs->trans($this->statuts[$status]), 'statut6', 'class="valignmiddle"');
157  } elseif ($status == 3) {
158  return img_picto($langs->trans($this->statuts[$status]), 'statut8', 'class="valignmiddle"');
159  }
160  } elseif ($mode == 3) {
161  if ($status == 0) {
162  return $langs->trans($this->statuts[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->statuts[$status]), 'statut1', 'class="valignmiddle"');
163  } elseif ($status == 2) {
164  return $langs->trans($this->statuts[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->statuts[$status]), 'statut6', 'class="valignmiddle"');
165  } elseif ($status == 3) {
166  return $langs->trans($this->statuts[$status]).' '.img_picto($langs->transnoentitiesnoconv($this->statuts[$status]), 'statut8', 'class="valignmiddle"');
167  }
168  }
169  //return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
170  }
171 
180  public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
181  {
182  $tables = array(
183  'prelevement_lignes'
184  );
185 
186  return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables);
187  }
188 }
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
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.