dolibarr 20.0.0
webportalpropal.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 . '/comm/propal/class/propal.class.php';
29
34{
38 public $module = 'webportal';
39
43 const ARRAY_STATUS_LABEL = array(
44 Propal::STATUS_DRAFT => 'PropalStatusDraftShort',
45 Propal::STATUS_VALIDATED => 'PropalStatusValidatedShort',
46 Propal::STATUS_SIGNED => 'PropalStatusSignedShort',
47 Propal::STATUS_NOTSIGNED => 'PropalStatusNotSignedShort',
48 Propal::STATUS_BILLED => 'PropalStatusBilledShort',
49 );
50
54 protected $propal_static = null;
55
95 // BEGIN MODULEBUILDER PROPERTIES
99 public $fields = array(
100 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id",),
101 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => '1', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1,),
102 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 2, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'validate' => 1, 'comment' => "Reference of object",),
103 'datep' => array('type' => 'date', 'label' => 'Date', 'enabled' => 1, 'visible' => 2, 'position' => 60,),
104 'fin_validite' => array('type' => 'date', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => 2, 'position' => 65,),
105 'total_ht' => array('type' => 'price', 'label' => 'TotalHT', 'enabled' => 1, 'visible' => 2, 'position' => 125, 'isameasure' => 1,),
106 'total_tva' => array('type' => 'price', 'label' => 'VAT', 'enabled' => 1, 'visible' => 2, 'position' => 130, 'isameasure' => 1,),
107 'total_ttc' => array('type' => 'price', 'label' => 'TotalTTC', 'enabled' => 1, 'visible' => 2, 'position' => 145, 'isameasure' => 1,),
108 'multicurrency_total_ht' => array('type' => 'price', 'label' => 'MulticurrencyAmountHT', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 245, 'isameasure' => 1,),
109 'multicurrency_total_tva' => array('type' => 'price', 'label' => 'MulticurrencyAmountVAT', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 250, 'isameasure' => 1,),
110 'multicurrency_total_ttc' => array('type' => 'price', 'label' => 'MulticurrencyAmountTTC', 'enabled' => 'isModEnabled("multicurrency")', 'visible' => -2, 'position' => 255, 'isameasure' => 1,),
111 'fk_statut' => array('type' => 'smallint(6)', 'label' => 'Status', 'enabled' => 1, 'visible' => 2, 'notnull' => 1, 'position' => 500, 'arrayofkeyval' => self::ARRAY_STATUS_LABEL,),
112 );
113 //public $rowid;
114 //public $ref;
115 //public $datep;
116 //public $fin_validite;
117 //public $total_ht;
118 //public $total_tva;
119 //public $total_ttc;
120 //public $multicurrency_total_ht;
121 //public $multicurrency_total_tva;
122 //public $multicurrency_total_ttc;
123 public $fk_statut;
124 // END MODULEBUILDER PROPERTIES
125
126
132 protected function getPropalStatic()
133 {
134 if (!$this->propal_static) {
135 $this->propal_static = new Propal($this->db);
136 }
137
138 return $this->propal_static;
139 }
140
146 public function __construct(DoliDB $db)
147 {
148 global $conf, $langs;
149
150 $this->db = $db;
151
152 $this->isextrafieldmanaged = 0;
153
154 $this->getPropalStatic();
155 }
156
164 public function getTooltipContentArray($params)
165 {
166 global $conf, $langs;
167
168 $datas = [];
169
170 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
171 return ['optimize' => $langs->trans("WebPortalPropal")];
172 }
173 $datas['picto'] = img_picto('', $this->picto) . ' <u>' . $langs->trans("WebPortalPropal") . '</u>';
174 if (isset($this->status)) {
175 $datas['picto'] .= ' ' . $this->getLibStatut(5);
176 }
177 $datas['ref'] .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
178
179 return $datas;
180 }
181
193 public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = -1)
194 {
195 global $conf, $hookmanager;
196
197 if (!empty($conf->dol_no_mouse_hover)) {
198 $notooltip = 1; // Force disable tooltips
199 }
200
201 $result = '';
202 $params = [
203 'id' => $this->id,
204 'objecttype' => $this->element,
205 'option' => $option,
206 'nofetch' => 1,
207 ];
208 $classfortooltip = 'classfortooltip';
209 $dataparams = '';
210 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
211 $classfortooltip = 'classforajaxtooltip';
212 $dataparams = ' data-params="' . dol_escape_htmltag(json_encode($params)) . '"';
213 $label = '';
214 } else {
215 $label = implode($this->getTooltipContentArray($params));
216 }
217
218 $url = '';
219 $option = 'nolink';
220
221 $linkclose = '';
222
223 $linkstart = '<a href="' . $url . '"';
224 $linkstart .= $linkclose . '>';
225 $linkend = '</a>';
226
227 if ($option === 'nolink') {
228 $linkstart = '';
229 $linkend = '';
230 }
231
232 $result .= $linkstart;
233 if ($withpicto) {
234 $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams . ' class="' . (($withpicto != 2) ? 'paddingright ' : '') . $classfortooltip . '"'), 0, 0, $notooltip ? 0 : 1);
235 }
236 if ($withpicto != 2) {
237 $result .= $this->ref;
238 }
239 $result .= $linkend;
240
241 global $action;
242 $hookmanager->initHooks(array($this->element . 'dao'));
243 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
244 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
245 if ($reshook > 0) {
246 $result = $hookmanager->resPrint;
247 } else {
248 $result .= $hookmanager->resPrint;
249 }
250 return $result;
251 }
252
260 public function getKanbanView($option = '', $arraydata = null)
261 {
262 global $conf, $langs;
263
264 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
265
266 $return = '<div class="box-flex-item box-flex-grow-zero">';
267 $return .= '<div class="info-box info-box-sm">';
268 $return .= '<span class="info-box-icon bg-infobox-action">';
269 $return .= img_picto('', $this->picto);
270 $return .= '</span>';
271 $return .= '<div class="info-box-content">';
272 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . (method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref) . '</span>';
273 if ($selected >= 0) {
274 $return .= '<input id="cb' . $this->id . '" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="' . $this->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
275 }
276 if (property_exists($this, 'label')) {
277 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">' . $this->label . '</div>';
278 }
279 if (property_exists($this, 'amount')) {
280 $return .= '<br>';
281 $return .= '<span class="info-box-label amount">' . price($this->amount, 0, $langs, 1, -1, -1, $conf->currency) . '</span>';
282 }
283 if (method_exists($this, 'getLibStatut')) {
284 $return .= '<br><div class="info-box-status margintoponly">' . $this->getLibStatut(3) . '</div>';
285 }
286 $return .= '</div>';
287 $return .= '</div>';
288 $return .= '</div>';
289
290 return $return;
291 }
292
299 public function getLabelStatus($mode = 0)
300 {
301 return $this->LibStatut($this->fk_statut, $mode);
302 }
303
310 public function getLibStatut($mode = 0)
311 {
312 return $this->LibStatut($this->fk_statut, $mode);
313 }
314
315 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
323 public function LibStatut($status, $mode = 0)
324 {
325 // phpcs:enable
326 return $this->getPropalStatic()->LibStatut($status, $mode);
327 }
328}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:636
Class to manage Dolibarr database access.
Class to manage proposals.
const STATUS_DRAFT
Draft status.
const STATUS_SIGNED
Signed quote.
const STATUS_NOTSIGNED
Not signed quote.
const STATUS_BILLED
Billed or processed quote.
const STATUS_VALIDATED
Validated status.
Class for WebPortalPropal.
const ARRAY_STATUS_LABEL
Status list (short label)
getPropalStatic()
Get propal for static method.
getLabelStatus($mode=0)
Return the label of the status.
getTooltipContentArray($params)
getTooltipContentArray
__construct(DoliDB $db)
Constructor.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getNomUrl($withpicto=0, $option='', $get_params='', $notooltip=0, $save_lastsearch_value=-1, $addlinktonotes=-1)
Return a link to the object card (with optionally the picto)
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the label of a given status.
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)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...