75 global $user, $langs, $conf;
79 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
80 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
81 $propalstatic =
new Propal($this->db);
82 $societestatic =
new Societe($this->db);
84 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ?
"" :
"Modified").
"Propals", $max));
86 if ($user->hasRight(
'propal',
'lire')) {
87 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
88 $sql .=
", s.code_client, s.code_compta, s.client";
89 $sql .=
", s.logo, s.email, s.entity";
90 $sql .=
", p.rowid, p.ref, p.fk_statut as status, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"societe as s";
92 if (empty($user->rights->societe->client->voir) && !$user->socid) {
93 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
95 $sql .=
" WHERE p.fk_soc = s.rowid";
96 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
97 if (empty($user->rights->societe->client->voir) && !$user->socid) {
98 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
101 $sql .=
" AND s.rowid = ".((int) $user->socid);
103 if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
104 $sql .=
" ORDER BY p.datep DESC, p.ref DESC ";
106 $sql .=
" ORDER BY p.tms DESC, p.ref DESC ";
108 $sql .= $this->db->plimit($max, 0);
110 $result = $this->db->query($sql);
112 $num = $this->db->num_rows($result);
117 while ($line < $num) {
118 $objp = $this->db->fetch_object($result);
119 $date = $this->db->jdate($objp->dp);
120 $datec = $this->db->jdate($objp->datec);
121 $datem = $this->db->jdate($objp->tms);
122 $dateterm = $this->db->jdate($objp->fin_validite);
123 $dateclose = $this->db->jdate($objp->date_cloture);
125 $propalstatic->id = $objp->rowid;
126 $propalstatic->ref = $objp->ref;
127 $propalstatic->total_ht = $objp->total_ht;
128 $propalstatic->total_tva = $objp->total_tva;
129 $propalstatic->total_ttc = $objp->total_ttc;
130 $propalstatic->statut = $objp->status;
131 $propalstatic->status = $objp->status;
132 $propalstatic->date = $date;
134 $societestatic->id = $objp->socid;
135 $societestatic->name = $objp->name;
137 $societestatic->code_client = $objp->code_client;
138 $societestatic->code_compta = $objp->code_compta;
139 $societestatic->client = $objp->client;
140 $societestatic->logo = $objp->logo;
141 $societestatic->email = $objp->email;
142 $societestatic->entity = $objp->entity;
145 if ($objp->status == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) {
149 $this->info_box_contents[$line][] = array(
150 'td' =>
'class="nowraponall"',
151 'text' => $propalstatic->getNomUrl(1),
156 $this->info_box_contents[$line][] = array(
157 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
158 'text' => $societestatic->getNomUrl(1),
162 $this->info_box_contents[$line][] = array(
163 'td' =>
'class="nowraponall right amount"',
164 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
167 $this->info_box_contents[$line][] = array(
172 $this->info_box_contents[$line][] = array(
173 'td' =>
'class="right" width="18"',
174 'text' => $propalstatic->LibStatut($objp->status, 3),
181 $this->info_box_contents[$line][0] = array(
182 'td' =>
'class="center"',
183 'text'=>$langs->trans(
"NoRecordedProposals"),
187 $this->db->free($result);
189 $this->info_box_contents[0][0] = array(
192 'text' => ($this->db->error().
' sql='.$sql),
196 $this->info_box_contents[0][0] = array(
197 'td' =>
'class="nohover opacitymedium left"',
198 'text' => $langs->trans(
"ReadPermissionNotAllowed")