dolibarr 20.0.0
webportalinvoice.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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
27// Put here all includes required by your class file
28require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
29
34{
38 public $module = 'webportal';
39
43 const ARRAY_STATUS_LABEL = array(
44 Facture::STATUS_DRAFT => 'BillShortStatusDraft',
45 Facture::STATUS_VALIDATED => 'BillShortStatusNotPaid',
46 Facture::STATUS_CLOSED => 'BillShortStatusPaid',
47 Facture::STATUS_ABANDONED => 'BillShortStatusCanceled',
48 );
49
53 protected $invoice_static = null;
54
94 // BEGIN MODULEBUILDER PROPERTIES
98 public $fields = array(
99 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 1,),
100 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => '1', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 20, 'index' => 1,),
101 'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'enabled' => 1, 'visible' => 2, 'notnull' => 1, 'showoncombobox' => 1, 'position' => 5,),
102 'type' => array('type' => 'smallint(6)', 'label' => 'Type', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 15,),
103 'datef' => array('type' => 'date', 'label' => 'DateInvoice', 'enabled' => 1, 'visible' => 2, 'position' => 20,),
104 'date_lim_reglement' => array('type' => 'date', 'label' => 'DateDue', 'enabled' => 1, 'visible' => 2, 'position' => 25,),
105 'paye' => array('type' => 'smallint(6)', 'label' => 'InvoicePaidCompletely', 'enabled' => 1, 'visible' => 0, 'notnull' => 1, 'position' => 80,),
106 'total_ht' => array('type' => 'price', 'label' => 'AmountHT', 'enabled' => 1, 'visible' => 2, 'position' => 95, 'isameasure' => 1,),
107 'total_tva' => array('type' => 'price', 'label' => 'AmountVAT', 'enabled' => 1, 'visible' => 2, 'position' => 100, 'isameasure' => 1,),
108 'total_ttc' => array('type' => 'price', 'label' => 'AmountTTC', 'enabled' => 1, 'visible' => 2, 'position' => 130, 'isameasure' => 1,),
109 'multicurrency_total_ht' => array('type' => 'price', 'label' => 'MulticurrencyAmountHT', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 290, 'isameasure' => 1,),
110 'multicurrency_total_tva' => array('type' => 'price', 'label' => 'MulticurrencyAmountVAT', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 291, 'isameasure' => 1,),
111 'multicurrency_total_ttc' => array('type' => 'price', 'label' => 'MulticurrencyAmountTTC', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 292, 'isameasure' => 1,),
112 'fk_statut' => array('type' => 'smallint(6)', 'label' => 'Status', 'enabled' => 1, 'visible' => 2, 'notnull' => 1, 'position' => 1000, 'arrayofkeyval' => self::ARRAY_STATUS_LABEL,),
113 );
114 //public $rowid;
115 //public $ref;
116 public $datef;
117 //public $date_lim_reglement;
118 //public $total_ht;
119 //public $total_tva;
120 //public $total_ttc;
121 //public $multicurrency_total_ht;
122 //public $multicurrency_total_tva;
123 //public $multicurrency_total_ttc;
124 public $fk_statut;
125 // END MODULEBUILDER PROPERTIES
126
127
133 protected function getInvoiceStatic()
134 {
135 if (!$this->invoice_static) {
136 $this->invoice_static = new Facture($this->db);
137 }
138
139 return $this->invoice_static;
140 }
141
147 public function __construct(DoliDB $db)
148 {
149 $this->db = $db;
150
151 $this->isextrafieldmanaged = 0;
152
153 $this->getInvoiceStatic();
154 }
155
163 public function getTooltipContentArray($params)
164 {
165 global $langs;
166
167 $langs->load('bills');
168
169 $datas = [];
170
171 return $datas;
172 }
173
188 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '')
189 {
190 global $langs, $conf;
191
192 if (!empty($conf->dol_no_mouse_hover)) {
193 $notooltip = 1; // Force disable tooltips
194 }
195
196 $result = '';
197
198 $url = '';
199 $option = 'nolink';
200
201 if ($short) {
202 return $url;
203 }
204
205 $picto = $this->picto;
206 if ($this->type == self::TYPE_REPLACEMENT) {
207 $picto .= 'r'; // Replacement invoice
208 }
209 if ($this->type == self::TYPE_CREDIT_NOTE) {
210 $picto .= 'a'; // Credit note
211 }
212 if ($this->type == self::TYPE_DEPOSIT) {
213 $picto .= 'd'; // Deposit invoice
214 }
215 $params = [
216 'id' => $this->id,
217 'objecttype' => $this->element,
218 'moretitle' => $moretitle,
219 'option' => $option,
220 ];
221 $classfortooltip = 'classfortooltip';
222 $dataparams = '';
223 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
224 $classfortooltip = 'classforajaxtooltip';
225 $dataparams = ' data-params="' . dol_escape_htmltag(json_encode($params)) . '"';
226 $label = '';
227 } else {
228 $label = implode($this->getTooltipContentArray($params));
229 }
230
231 $linkclose = ($target ? ' target="' . $target . '"' : '');
232
233 $linkstart = '<a href="' . $url . '"';
234 $linkstart .= $linkclose . '>';
235 $linkend = '</a>';
236
237 if ($option == 'nolink') {
238 $linkstart = '';
239 $linkend = '';
240 }
241
242 $result .= $linkstart;
243 if ($withpicto) {
244 $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams . ' class="' . (($withpicto != 2) ? 'paddingright ' : '') . $classfortooltip . '"'), 0, 0, $notooltip ? 0 : 1);
245 }
246 if ($withpicto != 2) {
247 $result .= ($max ? dol_trunc($this->ref, $max) : $this->ref);
248 }
249 $result .= $linkend;
250
251 global $action, $hookmanager;
252 $hookmanager->initHooks(array('invoicedao'));
253 $parameters = array('id' => $this->id, 'getnomurl' => &$result, 'notooltip' => $notooltip, 'addlinktonotes' => $addlinktonotes, 'save_lastsearch_value' => $save_lastsearch_value, 'target' => $target);
254 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
255 if ($reshook > 0) {
256 $result = $hookmanager->resPrint;
257 } else {
258 $result .= $hookmanager->resPrint;
259 }
260
261 return $result;
262 }
263
271 public function getKanbanView($option = '', $arraydata = null)
272 {
273 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
274
275 $return = '<div class="box-flex-item box-flex-grow-zero">';
276 $return .= '<div class="info-box info-box-sm">';
277 $return .= '<span class="info-box-icon bg-infobox-action">';
278 $return .= img_picto('', $this->picto);
279 //$return .= '<i class="fa fa-dol-action"></i>'; // Can be image
280 $return .= '</span>';
281 $return .= '<div class="info-box-content">';
282 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . (method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref) . '</span>';
283 $return .= '<input id="cb' . $this->id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
284 if (property_exists($this, 'socid')) {
285 $return .= '<br><span class="info-box-label">' . $this->socid . '</span>';
286 }
287 if (property_exists($this, 'fk_user_author')) {
288 $return .= '<br><span class="info-box-label">' . $this->fk_user_author . '</span>';
289 }
290 if (method_exists($this, 'getLibStatut')) {
291 $return .= '<br><div class="info-box-status margintoponly">' . $this->getLibStatut(3) . '</div>';
292 }
293 $return .= '</div>';
294 $return .= '</div>';
295 $return .= '</div>';
296
297 return $return;
298 }
299
306 public function getLabelStatus($mode = 0)
307 {
308 return $this->LibStatut($this->paye, $this->fk_statut, $mode, -1, $this->type);
309 }
310
318 public function getLibStatut($mode = 0, $alreadypaid = -1)
319 {
320 return $this->LibStatut($this->paye, $this->fk_statut, $mode, $alreadypaid, $this->type);
321 }
322
323 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
324
335 public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = -1)
336 {
337 // phpcs:enable
338 return $this->getInvoiceStatic()->LibStatut($paye, $status, $mode, $alreadypaid, $type);
339 }
340}
$object ref
Definition info.php:79
Class to manage Dolibarr database access.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
$paye
1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
const STATUS_VALIDATED
Validated (need to be paid)
const STATUS_ABANDONED
Classified abandoned and no payment done.
const STATUS_CLOSED
Classified paid.
Class for WebPortalInvoice.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
__construct(DoliDB $db)
Constructor.
getInvoiceStatic()
Get invoice for static methods.
LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=-1)
Return label of a status.
getLibStatut($mode=0, $alreadypaid=-1)
Return label of object status.
const ARRAY_STATUS_LABEL
Status list (short label)
getLabelStatus($mode=0)
Return the label of the status.
getNomUrl($withpicto=0, $option='', $max=0, $short=0, $moretitle='', $notooltip=0, $addlinktonotes=0, $save_lastsearch_value=-1, $target='')
Return clicable link of object (with eventually picto)
getTooltipContentArray($params)
getTooltipContentArray
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:139