dolibarr 21.0.0-beta
box_ficheinter.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
3 * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
4 * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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
27include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
28
29
34{
35 public $boxcode = "ficheinter";
36 public $boximg = "object_intervention";
37 public $boxlabel = "BoxFicheInter";
38 public $depends = array("ficheinter"); // conf->contrat->enabled
39
46 public function __construct($db, $param)
47 {
48 global $user;
49
50 $this->db = $db;
51
52 $this->hidden = !($user->hasRight('ficheinter', 'lire'));
53 $this->urltoaddentry = DOL_URL_ROOT.'/fichinter/card.php?action=create';
54 $this->msgNoRecords = 'NoRecordedInterventions';
55 }
56
63 public function loadBox($max = 10)
64 {
65 global $user, $langs, $conf;
66
67 $this->max = $max;
68
69 include_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
70 $ficheinterstatic = new Fichinter($this->db);
71 $thirdpartystatic = new Societe($this->db);
72
73 $this->info_box_head = array(
74 'text' => $langs->trans("BoxTitleLastFicheInter", $max).'<a class="paddingleft" href="'.DOL_URL_ROOT.'/fichinter/list.php?sortfield=f.tms&sortorder=DESC"><span class="badge">...</span></a>'
75 );
76
77 if ($user->hasRight('ficheinter', 'lire')) {
78 $sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut as status";
79 $sql .= ", f.datec";
80 $sql .= ", f.date_valid as datev";
81 $sql .= ", f.tms as datem";
82 $sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
83 $sql .= ", s.code_client, s.code_compta, s.client";
84 $sql .= ", s.logo, s.email, s.entity";
85 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
86 if (!$user->hasRight('societe', 'client', 'voir')) {
87 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
88 }
89 $sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
90 $sql .= " WHERE f.fk_soc = s.rowid ";
91 $sql .= " AND f.entity = ".$conf->entity;
92 if (!$user->hasRight('societe', 'client', 'voir')) {
93 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
94 }
95 if ($user->socid) {
96 $sql .= " AND s.rowid = ".((int) $user->socid);
97 }
98 $sql .= " ORDER BY f.tms DESC";
99 $sql .= $this->db->plimit($max, 0);
100
101 dol_syslog(get_class($this).'::loadBox', LOG_DEBUG);
102 $resql = $this->db->query($sql);
103 if ($resql) {
104 $num = $this->db->num_rows($resql);
105 $now = dol_now();
106
107 $i = 0;
108
109 while ($i < $num) {
110 $objp = $this->db->fetch_object($resql);
111 $datec = $this->db->jdate($objp->datec);
112 $datem = $this->db->jdate($objp->datem);
113
114 $ficheinterstatic->statut = $objp->status;
115 $ficheinterstatic->status = $objp->status;
116 $ficheinterstatic->id = $objp->rowid;
117 $ficheinterstatic->ref = $objp->ref;
118
119 $thirdpartystatic->id = $objp->socid;
120 $thirdpartystatic->name = $objp->name;
121 //$thirdpartystatic->name_alias = $objp->name_alias;
122 $thirdpartystatic->code_client = $objp->code_client;
123 $thirdpartystatic->code_compta = $objp->code_compta;
124 $thirdpartystatic->code_compta_client = $objp->code_compta;
125 $thirdpartystatic->client = $objp->client;
126 $thirdpartystatic->logo = $objp->logo;
127 $thirdpartystatic->email = $objp->email;
128 $thirdpartystatic->entity = $objp->entity;
129
130 $this->info_box_contents[$i][] = array(
131 'td' => 'class="nowraponall"',
132 'text' => $ficheinterstatic->getNomUrl(1),
133 'asis' => 1,
134 );
135
136 $this->info_box_contents[$i][] = array(
137 'td' => 'class="tdoverflowmax150"',
138 'text' => $thirdpartystatic->getNomUrl(1),
139 'asis' => 1,
140 );
141
142 $this->info_box_contents[$i][] = array(
143 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
144 'text' => dol_print_date($datem, 'day', 'tzuserrel'),
145 );
146
147 $this->info_box_contents[$i][] = array(
148 'td' => 'class="nowrap right"',
149 'text' => $ficheinterstatic->getLibStatut(3),
150 'asis' => 1,
151 );
152
153 $i++;
154 }
155
156 // if ($num == 0) {
157 // $this->info_box_contents[$i][0] = array(
158 // 'td' => 'class="center"',
159 // 'text' => '<span class="opacitymedium">'.$langs->trans("NoRecordedInterventions").'</span>'
160 // );
161 // }
162
163 $this->db->free($resql);
164 } else {
165 $this->info_box_contents[0][0] = array(
166 'td' => '',
167 'maxlength' => 500,
168 'text' => ($this->db->error().' sql='.$sql),
169 );
170 }
171 } else {
172 $this->info_box_contents[0][0] = array(
173 'td' => 'class="nohover left"',
174 'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
175 );
176 }
177 }
178
179
180
189 public function showBox($head = null, $contents = null, $nooutput = 0)
190 {
191 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
192 }
193}
Class ModeleBoxes.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage the box to show last interventions.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param)
Constructor.
loadBox($max=10)
Load data for box to show them later.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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