74 $textHead = $langs->trans(
"OpenedProjectsOpportunities");
75 $this->info_box_head = array(
'text' => $textHead,
'limit' =>
dol_strlen($textHead));
79 if ($user->hasRight(
'projet',
'lire')) {
80 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
81 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
82 $projectstatic =
new Project($this->db);
83 $companystatic =
new Societe($this->db);
90 if (!$user->hasRight(
'projet',
'all',
'lire')) {
91 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
94 $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,";
95 $sql .=
" s.nom as name, s.name_alias,";
96 $sql .=
" cls.code as opp_status_code";
97 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet as p";
98 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s on p.fk_soc = s.rowid";
99 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_lead_status as cls on p.fk_opp_status = cls.rowid";
100 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
101 $sql .=
" AND p.usage_opportunity = 1";
102 $sql .=
" AND p.fk_opp_status > 0";
103 $sql .=
" AND p.fk_statut IN (".$this->db->sanitize($projectstatic::STATUS_DRAFT.
",".$projectstatic::STATUS_VALIDATED).
")";
105 if (!$user->hasRight(
'projet',
'all',
'lire')) {
106 $sql .=
" AND p.rowid IN (".$this->db->sanitize($projectsListId).
")";
109 $sql .=
" ORDER BY p.datec DESC";
112 $result = $this->db->query($sql);
115 $num = $this->db->num_rows($result);
116 while ($i < min($num, $max)) {
117 $objp = $this->db->fetch_object($result);
119 $projectstatic->id = $objp->rowid;
120 $projectstatic->ref = $objp->ref;
121 $projectstatic->title = $objp->title;
122 $projectstatic->public = $objp->public;
123 $projectstatic->statut = $objp->status;
124 $projectstatic->opp_status = $objp->opp_status;
125 $projectstatic->opp_status_code = $objp->opp_status_code;
126 $projectstatic->opp_percent = $objp->opp_percent;
127 $projectstatic->opp_amount = $objp->opp_amount;
129 $companystatic->id = $objp->fk_soc;
130 $companystatic->name = $objp->name;
131 $companystatic->name_alias = $objp->name_alias;
133 $this->info_box_contents[$i][] = array(
134 'td' =>
'class="nowraponall"',
135 'text' => $projectstatic->getNomUrl(1),
139 $this->info_box_contents[$i][] = array(
140 'td' =>
'class="tdoverflowmax150 maxwidth200onsmartphone"',
141 'text' => $objp->title,
144 $this->info_box_contents[$i][] = array(
145 'td' =>
'class="tdoverflowmax100"',
146 'text' => ($objp->fk_soc > 0 ? $companystatic->getNomUrl(1) :
''),
150 $this->info_box_contents[$i][] = array(
'td' =>
'class="amount right nowraponall"',
'text' => ($projectstatic->opp_amount ?
price($projectstatic->opp_amount) :
''));
152 $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>');
154 $this->info_box_contents[$i][] = array(
'td' =>
'class="right"',
'text' => $projectstatic->getLibStatut(3));
159 $this->info_box_contents[$i][] = array(
'td' =>
'colspan="6"',
'text' =>
'...');
167 $this->info_box_contents[$i][] = array(
168 'tr' =>
'class="liste_total_wrap"',
169 'td' =>
'class="liste_total"',
170 'text' => $langs->trans(
"Total").
" ".$textHead,
172 $this->info_box_contents[$i][] = array(
173 'td' =>
'class="right liste_total" ',
174 'text' => round($num, 0).
" ".$langs->trans(
"Projects"),
176 $this->info_box_contents[$i][] = array(
177 'td' =>
'class="liste_total"',
180 $this->info_box_contents[$i][] = array(
181 'td' =>
'class="liste_total"',
184 $this->info_box_contents[$i][] = array(
185 'td' =>
'class="liste_total"',
188 $this->info_box_contents[$i][] = array(
189 'td' =>
'class="liste_total"',