dolibarr 20.0.0
webportalpartnership.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 . '/partnership/class/partnership.class.php';
29
34{
38 public $module = 'webportal';
39
43 const ARRAY_STATUS_LABEL = array(
44 Partnership::STATUS_DRAFT => 'Draft',
45 Partnership::STATUS_VALIDATED => 'Accepted',
46 Partnership::STATUS_APPROVED => 'Refused',
47 Partnership::STATUS_REFUSED => 'Suspended',
48 Partnership::STATUS_CANCELED => 'Terminated',
49 );
50
54 protected $partnership_static = null;
55
94 // BEGIN MODULEBUILDER PROPERTIES
98 public $fields = array(
99 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id",),
100 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'visible' => 5, 'noteditable' => 1, 'default' => '(PROV)', 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'comment' => "Reference of object", 'showonheader' => 1,),
101 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 1, 'position' => 15, 'notnull' => 1, 'visible' => -2, 'default' => '1', 'index' => 1,),
102
103 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label' => 'Type', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 5, 'csslist' => '',),
104 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => 1, 'position' => 50, 'notnull' => -1, 'visible' => 5, 'index' => 1, 'css' => '', 'csslist' => '',),
105 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 0,),
106 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 0,),
107 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2,),
108 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,),
109 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',),
110 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2,),
111 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0,),
112 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
113 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
114 'date_partnership_start' => array('type' => 'date', 'label' => 'DatePartnershipStart', 'enabled' => 1, 'position' => 52, 'notnull' => 1, 'visible' => 5,),
115 'date_partnership_end' => array('type' => 'date', 'label' => 'DatePartnershipEnd', 'enabled' => 1, 'position' => 53, 'notnull' => 0, 'visible' => 5,),
116 'url_to_check' => array('type' => 'varchar(255)', 'label' => 'UrlToCheck', 'enabled' => 1, 'position' => 70, 'notnull' => 0, 'visible' => -5,),
117 'count_last_url_check_error' => array('type' => 'integer', 'label' => 'CountLastUrlCheckError', 'enabled' => 1, 'position' => 71, 'notnull' => 0, 'visible' => -2, 'default' => '0',),
118 'last_check_backlink' => array('type' => 'datetime', 'label' => 'LastCheckBacklink', 'enabled' => 1, 'position' => 72, 'notnull' => 0, 'visible' => -2,),
119 'reason_decline_or_cancel' => array('type' => 'text', 'label' => 'ReasonDeclineOrCancel', 'enabled' => 1, 'position' => 73, 'notnull' => 0, 'visible' => -2,),
120 'ip' => array('type' => 'varchar(250)', 'label' => 'Ip', 'enabled' => 1, 'position' => 74, 'notnull' => 0, 'visible' => -2,),
121
122 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'visible' => 5, 'default' => '0', 'index' => 1, 'arrayofkeyval' => self::ARRAY_STATUS_LABEL, 'showonheader' => 1,),
123 );
124 //public $rowid;
125 //public $ref;
126 //public $entity;
127 //public $fk_type;
128 //public $note_public;
129 //public $note_private;
130 //public $date_creation;
131 //public $fk_user_creat;
132 //public $fk_user_modif;
133 //public $last_main_doc;
134 //public $import_key;
135 //public $model_pdf;
136 //public $date_partnership_start;
137 //public $date_partnership_end;
138 //public $url_to_check;
139 //public $count_last_url_check_error;
140 //public $last_check_backlink;
141 //public $reason_decline_or_cancel;
142 //public $fk_soc;
143 //public $fk_member;
144 //public $ip;
145 //public $status;
146 // END MODULEBUILDER PROPERTIES
147
153 protected function getPartnershipStatic()
154 {
155 if (!$this->partnership_static) {
156 $this->partnership_static = new Partnership($this->db);
157 }
158
159 return $this->partnership_static;
160 }
161
167 public function __construct(DoliDB $db)
168 {
169 global $langs;
170
171 $this->db = $db;
172
173 $this->isextrafieldmanaged = 0;
174
175 $this->getPartnershipStatic();
176
177 // Translate some data of arrayofkeyval
178 if (is_object($langs)) {
179 foreach ($this->fields as $key => $val) {
180 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
181 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
182 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
183 }
184 }
185 }
186 }
187 }
188
196 public function getTooltipContentArray($params)
197 {
198 global $conf, $langs;
199
200 $datas = [];
201
202 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
203 return ['optimize' => $langs->trans("WebPortalPartnership")];
204 }
205 $datas['picto'] = img_picto('', $this->picto) . ' <u>' . $langs->trans("WebPortalPartnership") . '</u>';
206 if (isset($this->status)) {
207 $datas['picto'] .= ' ' . $this->getLibStatut(5);
208 }
209 $datas['ref'] .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
210
211 return $datas;
212 }
213
224 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
225 {
226 global $conf, $langs, $hookmanager;
227
228 if (!empty($conf->dol_no_mouse_hover)) {
229 $notooltip = 1; // Force disable tooltips
230 }
231
232 $option = 'nolink';
233
234 $result = '';
235 $params = [
236 'id' => $this->id,
237 'objecttype' => $this->element,
238 'option' => $option,
239 ];
240 $classfortooltip = 'classfortooltip';
241 $dataparams = '';
242 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
243 $classfortooltip = 'classforajaxtooltip';
244 $dataparams = ' data-params="' . dol_escape_htmltag(json_encode($params)) . '"';
245 $label = '';
246 } else {
247 $label = implode($this->getTooltipContentArray($params));
248 }
249
250 $url = '';
251 //$url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
252
253 if ($option != 'nolink') {
254 // Add param to save lastsearch_values or not
255 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
256 if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
257 $add_save_lastsearch_values = 1;
258 }
259 if ($add_save_lastsearch_values) {
260 $url .= '&save_lastsearch_values=1';
261 }
262 }
263
264 $linkclose = '';
265 if (empty($notooltip)) {
266 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
267 $label = $langs->trans("ShowPartnership");
268 $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"';
269 }
270 $linkclose .= ($label ? ' title="' . dol_escape_htmltag($label, 1) . '"' : ' title="tocomplete"');
271 $linkclose .= $dataparams . ' class="' . $classfortooltip . ($morecss ? ' ' . $morecss : '') . '"';
272 } else {
273 $linkclose = ($morecss ? ' class="' . $morecss . '"' : '');
274 }
275
276 if ($option == 'nolink') {
277 $linkstart = '<span';
278 } else {
279 $linkstart = '<a href="' . $url . '"';
280 }
281 $linkstart .= $linkclose . '>';
282 if ($option == 'nolink') {
283 $linkend = '</span>';
284 } else {
285 $linkend = '</a>';
286 }
287
288 $result .= $linkstart;
289
290 if (empty($this->showphoto_on_popup)) {
291 if ($withpicto) {
292 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams . ' class="' . (($withpicto != 2) ? 'paddingright ' : '') . $classfortooltip . '"'), 0, 0, $notooltip ? 0 : 1);
293 }
294 } else {
295 if ($withpicto) {
296 require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
297
298 list($class, $module) = explode('@', $this->picto);
299 $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref);
300 $filearray = dol_dir_list($upload_dir, "files");
301 $filename = $filearray[0]['name'];
302 if (!empty($filename)) {
303 $pospoint = strpos($filearray[0]['name'], '.');
304
305 $pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint);
306 if (!getDolGlobalString(strtoupper($module . '_' . $class) . '_FORMATLISTPHOTOSASUSERS')) {
307 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo' . $module . '" alt="No photo" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $module . '&entity=' . $conf->entity . '&file=' . urlencode($pathtophoto) . '"></div></div>';
308 } else {
309 $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $module . '&entity=' . $conf->entity . '&file=' . urlencode($pathtophoto) . '"></div>';
310 }
311
312 $result .= '</div>';
313 } else {
314 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
315 }
316 }
317 }
318
319 if ($withpicto != 2) {
320 $result .= $this->ref;
321 }
322
323 $result .= $linkend;
324 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
325
326 global $action, $hookmanager;
327 $hookmanager->initHooks(array('partnershipdao'));
328 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
329 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
330 if ($reshook > 0) {
331 $result = $hookmanager->resPrint;
332 } else {
333 $result .= $hookmanager->resPrint;
334 }
335
336 return $result;
337 }
338
345 public function getLibStatut($mode = 0)
346 {
347 return $this->LibStatut($this->status, $mode);
348 }
349
350 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
351
359 public function LibStatut($status, $mode = 0)
360 {
361 // phpcs:enable
362 return $this->getPartnershipStatic()->LibStatut($status, $mode);
363 }
364}
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
$object ref
Definition info.php:79
Class to manage Dolibarr database access.
Class for Partnership.
Class for WebPortalPartnership.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
getTooltipContentArray($params)
getTooltipContentArray
__construct(DoliDB $db)
Constructor.
const ARRAY_STATUS_LABEL
Status list (short label)
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
getPartnershipStatic()
Get partnership for static method.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string 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...