65 global $user, $langs, $conf;
69 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
70 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
71 $propalstatic =
new Propal($this->db);
72 $societestatic =
new Societe($this->db);
74 $text = $langs->trans(
"BoxTitleLast".(
getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"Propals", $max);
75 $this->info_box_head = array(
76 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/comm/propal/list.php?sortfield=p.tms&sortorder=DESC"><span class="badge">...</span></a>'
79 if ($user->hasRight(
'propal',
'lire')) {
80 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
81 $sql .=
", s.code_client, s.code_compta, s.client";
82 $sql .=
", s.logo, s.email, s.entity";
83 $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";
84 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"societe as s";
85 if (!$user->hasRight(
'societe',
'client',
'voir')) {
86 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
88 $sql .=
" WHERE p.fk_soc = s.rowid";
89 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
90 if (!$user->hasRight(
'societe',
'client',
'voir')) {
91 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
94 $sql .=
" AND s.rowid = ".((int) $user->socid);
97 $sql .=
" ORDER BY p.datep DESC, p.ref DESC ";
99 $sql .=
" ORDER BY p.tms DESC, p.ref DESC ";
101 $sql .= $this->db->plimit($max, 0);
103 $result = $this->db->query($sql);
105 $num = $this->db->num_rows($result);
110 while ($line < $num) {
111 $objp = $this->db->fetch_object($result);
112 $date = $this->db->jdate($objp->dp);
113 $datec = $this->db->jdate($objp->datec);
114 $datem = $this->db->jdate($objp->tms);
115 $dateterm = $this->db->jdate($objp->fin_validite);
116 $dateclose = $this->db->jdate($objp->date_cloture);
118 $propalstatic->id = $objp->rowid;
119 $propalstatic->ref = $objp->ref;
120 $propalstatic->total_ht = $objp->total_ht;
121 $propalstatic->total_tva = $objp->total_tva;
122 $propalstatic->total_ttc = $objp->total_ttc;
123 $propalstatic->statut = $objp->status;
124 $propalstatic->status = $objp->status;
125 $propalstatic->date = $date;
127 $societestatic->id = $objp->socid;
128 $societestatic->name = $objp->name;
130 $societestatic->code_client = $objp->code_client;
131 $societestatic->code_compta = $objp->code_compta;
132 $societestatic->code_compta_client = $objp->code_compta;
133 $societestatic->client = $objp->client;
134 $societestatic->logo = $objp->logo;
135 $societestatic->email = $objp->email;
136 $societestatic->entity = $objp->entity;
139 if ($objp->status == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) {
143 $this->info_box_contents[$line][] = array(
144 'td' =>
'class="nowraponall"',
145 'text' => $propalstatic->getNomUrl(1),
150 $this->info_box_contents[$line][] = array(
151 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
152 'text' => $societestatic->getNomUrl(1),
156 $this->info_box_contents[$line][] = array(
157 'td' =>
'class="nowraponall right amount"',
158 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
161 $this->info_box_contents[$line][] = array(
166 $this->info_box_contents[$line][] = array(
167 'td' =>
'class="right" width="18"',
168 'text' => $propalstatic->LibStatut($objp->status, 3),
175 $this->info_box_contents[$line][0] = array(
176 'td' =>
'class="center"',
177 'text' => $langs->trans(
"NoRecordedProposals"),
181 $this->db->free($result);
183 $this->info_box_contents[0][0] = array(
186 'text' => ($this->db->error().
' sql='.$sql),
190 $this->info_box_contents[0][0] = array(
191 'td' =>
'class="nohover left"',
192 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'