71 $textHead = $langs->trans(
"OpenedProjectsOpportunities");
72 $this->info_box_head = array(
'text' => $textHead,
'limit'=>
dol_strlen($textHead));
76 if ($user->hasRight(
'projet',
'lire')) {
77 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
78 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
79 $projectstatic =
new Project($this->db);
80 $companystatic =
new Societe($this->db);
87 if (!$user->hasRight(
'projet',
'all',
'lire')) {
88 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
91 $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,";
92 $sql .=
" s.nom as name, s.name_alias,";
93 $sql .=
" cls.code as opp_status_code";
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
95 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
96 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_lead_status as cls on p.fk_opp_status = cls.rowid";
97 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
98 $sql .=
" AND p.usage_opportunity = 1";
99 $sql .=
" AND p.fk_opp_status > 0";
100 $sql .=
" AND p.fk_statut IN (".$this->db->sanitize($projectstatic::STATUS_DRAFT.
",".$projectstatic::STATUS_VALIDATED).
")";
102 if (!$user->hasRight(
'projet',
'all',
'lire')) {
103 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
106 $sql .=
" ORDER BY p.datec DESC";
109 $result = $this->db->query($sql);
112 $num = $this->db->num_rows($result);
113 while ($i < min($num, $max)) {
114 $objp = $this->db->fetch_object($result);
116 $projectstatic->id = $objp->rowid;
117 $projectstatic->ref = $objp->ref;
118 $projectstatic->title = $objp->title;
119 $projectstatic->public = $objp->public;
120 $projectstatic->statut = $objp->status;
121 $projectstatic->opp_status = $objp->opp_status;
122 $projectstatic->opp_status_code = $objp->opp_status_code;
123 $projectstatic->opp_percent = $objp->opp_percent;
124 $projectstatic->opp_amount = $objp->opp_amount;
126 $companystatic->id = $objp->fk_soc;
127 $companystatic->name = $objp->name;
128 $companystatic->name_alias = $objp->name_alias;
130 $this->info_box_contents[$i][] = array(
131 'td' =>
'class="nowraponall"',
132 'text' => $projectstatic->getNomUrl(1),
136 $this->info_box_contents[$i][] = array(
137 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
138 'text' => $objp->title,
141 $this->info_box_contents[$i][] = array(
142 'td' =>
'class="tdoverflowmax100"',
143 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
147 $this->info_box_contents[$i][] = array(
'td' =>
'class="amount right nowraponall"',
'text' => ($projectstatic->opp_amount ?
price($projectstatic->opp_amount) :
''));
149 $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>');
151 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
156 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
164 $this->info_box_contents[$i][] = array(
165 'tr' =>
'class="liste_total_wrap"',
166 'td' =>
'class="liste_total"',
167 'text' => $langs->trans(
"Total").
" ".$textHead,
169 $this->info_box_contents[$i][] = array(
170 'td' =>
'class="right liste_total" ',
171 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
173 $this->info_box_contents[$i][] = array(
174 'td' =>
'class="liste_total"',
177 $this->info_box_contents[$i][] = array(
178 'td' =>
'class="liste_total"',
181 $this->info_box_contents[$i][] = array(
182 'td' =>
'class="liste_total"',
185 $this->info_box_contents[$i][] = array(
186 'td' =>
'class="liste_total"',