dolibarr 21.0.0-alpha
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
128 public $fk_statut;
129 // END MODULEBUILDER PROPERTIES
130
131
137 protected function getInvoiceStatic()
138 {
139 if (!$this->invoice_static) {
140 $this->invoice_static = new Facture($this->db);
141 }
142
143 return $this->invoice_static;
144 }
145
151 public function __construct(DoliDB $db)
152 {
153 $this->db = $db;
154
155 $this->isextrafieldmanaged = 0;
156
157 $this->getInvoiceStatic();
158 }
159
166 public function getTooltipContentArray($params)
167 {
168 global $langs;
169
170 $langs->load('bills');
171
172 $datas = [];
173
174 return $datas;
175 }
176
191 public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1, $target = '')
192 {
193 global $langs, $conf;
194
195 if (!empty($conf->dol_no_mouse_hover)) {
196 $notooltip = 1; // Force disable tooltips
197 }
198
199 $result = '';
200
201 $url = '';
202 $option = 'nolink';
203
204 if ($short) {
205 return $url;
206 }
207
208 $picto = $this->picto;
209 if ($this->type == self::TYPE_REPLACEMENT) {
210 $picto .= 'r'; // Replacement invoice
211 }
212 if ($this->type == self::TYPE_CREDIT_NOTE) {
213 $picto .= 'a'; // Credit note
214 }
215 if ($this->type == self::TYPE_DEPOSIT) {
216 $picto .= 'd'; // Deposit invoice
217 }
218 $params = [
219 'id' => $this->id,
220 'objecttype' => $this->element,
221 'moretitle' => $moretitle,
222 'option' => $option,
223 ];
224 $classfortooltip = 'classfortooltip';
225 $dataparams = '';
226 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
227 $classfortooltip = 'classforajaxtooltip';
228 $dataparams = ' data-params="' . dol_escape_htmltag(json_encode($params)) . '"';
229 $label = '';
230 } else {
231 $label = implode($this->getTooltipContentArray($params));
232 }
233
234 $linkclose = ($target ? ' target="' . $target . '"' : '');
235
236 $linkstart = '<a href="' . $url . '"';
237 $linkstart .= $linkclose . '>';
238 $linkend = '</a>';
239
240 if ($option == 'nolink') {
241 $linkstart = '';
242 $linkend = '';
243 }
244
245 $result .= $linkstart;
246 if ($withpicto) {
247 $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams . ' class="' . (($withpicto != 2) ? 'paddingright ' : '') . $classfortooltip . '"'), 0, 0, $notooltip ? 0 : 1);
248 }
249 if ($withpicto != 2) {
250 $result .= ($max ? dol_trunc($this->ref, $max) : $this->ref);
251 }
252 $result .= $linkend;
253
254 global $action, $hookmanager;
255 $hookmanager->initHooks(array('invoicedao'));
256 $parameters = array('id' => $this->id, 'getnomurl' => &$result, 'notooltip' => $notooltip, 'addlinktonotes' => $addlinktonotes, 'save_lastsearch_value' => $save_lastsearch_value, 'target' => $target);
257 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
258 if ($reshook > 0) {
259 $result = $hookmanager->resPrint;
260 } else {
261 $result .= $hookmanager->resPrint;
262 }
263
264 return $result;
265 }
266
274 public function getKanbanView($option = '', $arraydata = null)
275 {
276 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
277
278 $return = '<div class="box-flex-item box-flex-grow-zero">';
279 $return .= '<div class="info-box info-box-sm">';
280 $return .= '<span class="info-box-icon bg-infobox-action">';
281 $return .= img_picto('', $this->picto);
282 //$return .= '<i class="fa fa-dol-action"></i>'; // Can be image
283 $return .= '</span>';
284 $return .= '<div class="info-box-content">';
285 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . (method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref) . '</span>';
286 $return .= '<input id="cb' . $this->id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
287 if (property_exists($this, 'socid')) {
288 $return .= '<br><span class="info-box-label">' . $this->socid . '</span>';
289 }
290 if (property_exists($this, 'fk_user_author')) {
291 $return .= '<br><span class="info-box-label">' . $this->fk_user_author . '</span>';
292 }
293 if (method_exists($this, 'getLibStatut')) {
294 $return .= '<br><div class="info-box-status margintoponly">' . $this->getLibStatut(3) . '</div>';
295 }
296 $return .= '</div>';
297 $return .= '</div>';
298 $return .= '</div>';
299
300 return $return;
301 }
302
309 public function getLabelStatus($mode = 0)
310 {
311 return $this->LibStatut($this->paye, $this->fk_statut, $mode, -1, $this->type);
312 }
313
321 public function getLibStatut($mode = 0, $alreadypaid = -1)
322 {
323 return $this->LibStatut($this->paye, $this->fk_statut, $mode, $alreadypaid, $this->type);
324 }
325
326 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
327
338 public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = -1)
339 {
340 // phpcs:enable
341 return $this->getInvoiceStatic()->LibStatut($paye, $status, $mode, $alreadypaid, $type);
342 }
343}
$object ref
Definition info.php:79
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...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137