64 global $user, $langs, $conf;
68 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
69 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
70 $propalstatic =
new Propal($this->db);
71 $societestatic =
new Societe($this->db);
73 $text = $langs->trans(
"BoxTitleLast".(
getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"Propals", $max);
74 $this->info_box_head = array(
75 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/comm/propal/list.php?sortfield=p.tms&sortorder=DESC"><span class="badge">...</span></a>'
78 if ($user->hasRight(
'propal',
'lire')) {
79 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
80 $sql .=
", s.code_client, s.code_compta, s.client";
81 $sql .=
", s.logo, s.email, s.entity";
82 $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";
83 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"societe as s";
84 if (!$user->hasRight(
'societe',
'client',
'voir')) {
85 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
87 $sql .=
" WHERE p.fk_soc = s.rowid";
88 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
89 if (!$user->hasRight(
'societe',
'client',
'voir')) {
90 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
93 $sql .=
" AND s.rowid = ".((int) $user->socid);
96 $sql .=
" ORDER BY p.datep DESC, p.ref DESC ";
98 $sql .=
" ORDER BY p.tms DESC, p.ref DESC ";
100 $sql .= $this->db->plimit($max, 0);
102 $result = $this->db->query($sql);
104 $num = $this->db->num_rows($result);
109 while ($line < $num) {
110 $objp = $this->db->fetch_object($result);
111 $date = $this->db->jdate($objp->dp);
112 $datec = $this->db->jdate($objp->datec);
113 $datem = $this->db->jdate($objp->tms);
114 $dateterm = $this->db->jdate($objp->fin_validite);
115 $dateclose = $this->db->jdate($objp->date_cloture);
117 $propalstatic->id = $objp->rowid;
118 $propalstatic->ref = $objp->ref;
119 $propalstatic->total_ht = $objp->total_ht;
120 $propalstatic->total_tva = $objp->total_tva;
121 $propalstatic->total_ttc = $objp->total_ttc;
122 $propalstatic->statut = $objp->status;
123 $propalstatic->status = $objp->status;
124 $propalstatic->date = $date;
126 $societestatic->id = $objp->socid;
127 $societestatic->name = $objp->name;
129 $societestatic->code_client = $objp->code_client;
130 $societestatic->code_compta = $objp->code_compta;
131 $societestatic->client = $objp->client;
132 $societestatic->logo = $objp->logo;
133 $societestatic->email = $objp->email;
134 $societestatic->entity = $objp->entity;
137 if ($objp->status == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) {
141 $this->info_box_contents[$line][] = array(
142 'td' =>
'class="nowraponall"',
143 'text' => $propalstatic->getNomUrl(1),
148 $this->info_box_contents[$line][] = array(
149 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
150 'text' => $societestatic->getNomUrl(1),
154 $this->info_box_contents[$line][] = array(
155 'td' =>
'class="nowraponall right amount"',
156 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
159 $this->info_box_contents[$line][] = array(
164 $this->info_box_contents[$line][] = array(
165 'td' =>
'class="right" width="18"',
166 'text' => $propalstatic->LibStatut($objp->status, 3),
173 $this->info_box_contents[$line][0] = array(
174 'td' =>
'class="center"',
175 'text'=>$langs->trans(
"NoRecordedProposals"),
179 $this->db->free($result);
181 $this->info_box_contents[0][0] = array(
184 'text' => ($this->db->error().
' sql='.$sql),
188 $this->info_box_contents[0][0] = array(
189 'td' =>
'class="nohover left"',
190 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'