dolibarr 21.0.0-beta
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;
119 public $datef;
120 //public $date_lim_reglement;
121 //public $total_ht;
122 //public $total_tva;
123 //public $total_ttc;
124 //public $multicurrency_total_ht;
125 //public $multicurrency_total_tva;
126 //public $multicurrency_total_ttc;
127
131 public $fk_statut;
132 // END MODULEBUILDER PROPERTIES
133
134
140 protected function getInvoiceStatic()
141 {
142 if (!$this->invoice_static) {
143 $this->invoice_static = new Facture($this->db);
144 }
145
146 return $this->invoice_static;
147 }
148
154 public function __construct(DoliDB $db)
155 {
156 $this->db = $db;
157
158 $this->isextrafieldmanaged = 0;
159
160 $this->getInvoiceStatic();
161 }
162
169 public function getTooltipContentArray($params)
170 {
171 global $langs;
172
173 $langs->load('bills');
174
175 $datas = [];
176
177 return $datas;
178 }
179
194 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '')
195 {
196 global $langs, $conf;
197
198 if (!empty($conf->dol_no_mouse_hover)) {
199 $notooltip = 1; // Force disable tooltips
200 }
201
202 $result = '';
203
204 $url = '';
205 $option = 'nolink';
206
207 if ($short) {
208 return $url;
209 }
210
211 $picto = $this->picto;
212 if ($this->type == self::TYPE_REPLACEMENT) {
213 $picto .= 'r'; // Replacement invoice
214 }
215 if ($this->type == self::TYPE_CREDIT_NOTE) {
216 $picto .= 'a'; // Credit note
217 }
218 if ($this->type == self::TYPE_DEPOSIT) {
219 $picto .= 'd'; // Deposit invoice
220 }
221 $params = [
222 'id' => $this->id,
223 'objecttype' => $this->element,
224 'moretitle' => $moretitle,
225 'option' => $option,
226 ];
227 $classfortooltip = 'classfortooltip';
228 $dataparams = '';
229 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
230 $classfortooltip = 'classforajaxtooltip';
231 $dataparams = ' data-params="' . dol_escape_htmltag(json_encode($params)) . '"';
232 $label = '';
233 } else {
234 $label = implode($this->getTooltipContentArray($params));
235 }
236
237 $linkclose = ($target ? ' target="' . $target . '"' : '');
238
239 $linkstart = '<a href="' . $url . '"';
240 $linkstart .= $linkclose . '>';
241 $linkend = '</a>';
242
243 if ($option == 'nolink') {
244 $linkstart = '';
245 $linkend = '';
246 }
247
248 $result .= $linkstart;
249 if ($withpicto) {
250 $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams . ' class="' . (($withpicto != 2) ? 'paddingright ' : '') . $classfortooltip . '"'), 0, 0, $notooltip ? 0 : 1);
251 }
252 if ($withpicto != 2) {
253 $result .= ($max ? dol_trunc($this->ref, $max) : $this->ref);
254 }
255 $result .= $linkend;
256
257 global $action, $hookmanager;
258 $hookmanager->initHooks(array('invoicedao'));
259 $parameters = array('id' => $this->id, 'getnomurl' => &$result, 'notooltip' => $notooltip, 'addlinktonotes' => $addlinktonotes, 'save_lastsearch_value' => $save_lastsearch_value, 'target' => $target);
260 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
261 if ($reshook > 0) {
262 $result = $hookmanager->resPrint;
263 } else {
264 $result .= $hookmanager->resPrint;
265 }
266
267 return $result;
268 }
269
277 public function getKanbanView($option = '', $arraydata = null)
278 {
279 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
280
281 $return = '<div class="box-flex-item box-flex-grow-zero">';
282 $return .= '<div class="info-box info-box-sm">';
283 $return .= '<span class="info-box-icon bg-infobox-action">';
284 $return .= img_picto('', $this->picto);
285 //$return .= '<i class="fa fa-dol-action"></i>'; // Can be image
286 $return .= '</span>';
287 $return .= '<div class="info-box-content">';
288 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . (method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref) . '</span>';
289 $return .= '<input id="cb' . $this->id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
290 if (property_exists($this, 'socid')) {
291 $return .= '<br><span class="info-box-label">' . $this->socid . '</span>';
292 }
293 if (property_exists($this, 'fk_user_author')) {
294 $return .= '<br><span class="info-box-label">' . $this->fk_user_author . '</span>';
295 }
296 if (method_exists($this, 'getLibStatut')) {
297 $return .= '<br><div class="info-box-status margintoponly">' . $this->getLibStatut(3) . '</div>';
298 }
299 $return .= '</div>';
300 $return .= '</div>';
301 $return .= '</div>';
302
303 return $return;
304 }
305
312 public function getLabelStatus($mode = 0)
313 {
314 return $this->LibStatut($this->paye, $this->fk_statut, $mode, -1, $this->type);
315 }
316
324 public function getLibStatut($mode = 0, $alreadypaid = -1)
325 {
326 return $this->LibStatut($this->paye, $this->fk_statut, $mode, $alreadypaid, $this->type);
327 }
328
329 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
330
341 public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = -1)
342 {
343 // phpcs:enable
344 return $this->getInvoiceStatic()->LibStatut($paye, $status, $mode, $alreadypaid, $type);
345 }
346}
$object ref
Definition info.php:89
Class to manage Dolibarr database access.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
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 clickable 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 clickable 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:149