81 $textHead = $langs->trans(
"OpenedProjectsOpportunities");
82 $this->info_box_head = array(
'text' => $textHead,
'limit'=>
dol_strlen($textHead));
86 if ($user->hasRight(
'projet',
'lire')) {
87 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
88 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
89 $projectstatic =
new Project($this->db);
90 $companystatic =
new Societe($this->db);
97 if (!$user->hasRight(
'projet',
'all',
'lire')) {
98 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
101 $sql =
"SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_percent, p.opp_amount, p.public,";
102 $sql .=
" s.nom as name, s.name_alias,";
103 $sql .=
" cls.code as opp_status_code";
104 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
105 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
106 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_lead_status as cls on p.fk_opp_status = cls.rowid";
107 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
108 $sql .=
" AND p.usage_opportunity = 1";
109 $sql .=
" AND p.fk_opp_status > 0";
110 $sql .=
" AND p.fk_statut IN (".$this->db->sanitize($projectstatic::STATUS_DRAFT.
",".$projectstatic::STATUS_VALIDATED).
")";
112 if (!$user->hasRight(
'projet',
'all',
'lire')) {
113 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
116 $sql .=
" ORDER BY p.datec DESC";
119 $result = $this->db->query($sql);
122 $num = $this->db->num_rows($result);
123 while ($i < min($num, $max)) {
124 $objp = $this->db->fetch_object($result);
126 $projectstatic->id = $objp->rowid;
127 $projectstatic->ref = $objp->ref;
128 $projectstatic->title = $objp->title;
129 $projectstatic->public = $objp->public;
130 $projectstatic->statut = $objp->status;
131 $projectstatic->opp_status = $objp->opp_status;
132 $projectstatic->opp_status_code = $objp->opp_status_code;
133 $projectstatic->opp_percent = $objp->opp_percent;
134 $projectstatic->opp_amount = $objp->opp_amount;
136 $companystatic->id = $objp->fk_soc;
137 $companystatic->name = $objp->name;
138 $companystatic->name_alias = $objp->name_alias;
140 $this->info_box_contents[$i][] = array(
141 'td' =>
'class="nowraponall"',
142 'text' => $projectstatic->getNomUrl(1),
146 $this->info_box_contents[$i][] = array(
147 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
148 'text' => $objp->title,
151 $this->info_box_contents[$i][] = array(
152 'td' =>
'class="tdoverflowmax100"',
153 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
157 $this->info_box_contents[$i][] = array(
'td' =>
'class="amount right nowraponall"',
'text' => ($projectstatic->opp_amount ?
price($projectstatic->opp_amount) :
''));
159 $this->info_box_contents[$i][] = array(
'td' =>
'class="nowraponall"',
'asis'=>1,
'text' => ($projectstatic->opp_status_code ? $langs->trans(
"OppStatus".$projectstatic->opp_status_code).
' ' :
'').
'<span class="opacitymedium small">('.round($projectstatic->opp_percent).
'%)</span>');
161 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
166 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
174 $this->info_box_contents[$i][] = array(
175 'tr' =>
'class="liste_total_wrap"',
176 'td' =>
'class="liste_total"',
177 'text' => $langs->trans(
"Total").
" ".$textHead,
179 $this->info_box_contents[$i][] = array(
180 'td' =>
'class="right liste_total" ',
181 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
183 $this->info_box_contents[$i][] = array(
184 'td' =>
'class="liste_total"',
187 $this->info_box_contents[$i][] = array(
188 'td' =>
'class="liste_total"',
191 $this->info_box_contents[$i][] = array(
192 'td' =>
'class="liste_total"',
195 $this->info_box_contents[$i][] = array(
196 'td' =>
'class="liste_total"',