68 global $user, $langs,
$conf;
72 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
73 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
74 $propalstatic =
new Propal($this->db);
75 $societestatic =
new Societe($this->db);
77 $text = $langs->trans(
"BoxTitleLast".(
getDolGlobalString(
'MAIN_LASTBOX_ON_OBJECT_DATE') ?
"" :
"Modified").
"Propals", $max);
78 $this->info_box_head = array(
79 'text' => $text.
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/comm/propal/list.php?sortfield=p.tms&sortorder=DESC"><span class="badge">...</span></a>'
82 if ($user->hasRight(
'propal',
'lire')) {
83 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
84 $sql .=
", s.code_client, s.code_compta, s.client";
85 $sql .=
", s.logo, s.email, s.entity";
86 $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";
87 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p, ".MAIN_DB_PREFIX.
"societe as s";
88 if (!$user->hasRight(
'societe',
'client',
'voir')) {
89 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
91 $sql .=
" WHERE p.fk_soc = s.rowid";
92 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
93 if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
97 $sql .=
" AND s.rowid = ".((int) $user->socid);
100 $sql .=
" ORDER BY p.datep DESC, p.ref DESC ";
102 $sql .=
" ORDER BY p.tms DESC, p.ref DESC ";
104 $sql .= $this->db->plimit($max, 0);
106 $result = $this->db->query($sql);
108 $num = $this->db->num_rows($result);
113 while ($line < $num) {
114 $objp = $this->db->fetch_object($result);
115 $date = $this->db->jdate($objp->dp);
116 $datec = $this->db->jdate($objp->datec);
117 $datem = $this->db->jdate($objp->tms);
118 $dateterm = $this->db->jdate($objp->fin_validite);
119 $dateclose = $this->db->jdate($objp->date_cloture);
121 $propalstatic->id = $objp->rowid;
122 $propalstatic->ref = $objp->ref;
123 $propalstatic->total_ht = $objp->total_ht;
124 $propalstatic->total_tva = $objp->total_tva;
125 $propalstatic->total_ttc = $objp->total_ttc;
126 $propalstatic->statut = $objp->status;
127 $propalstatic->status = $objp->status;
128 $propalstatic->date = $date;
130 $societestatic->id = $objp->socid;
131 $societestatic->name = $objp->name;
133 $societestatic->code_client = $objp->code_client;
134 $societestatic->code_compta = $objp->code_compta;
135 $societestatic->code_compta_client = $objp->code_compta;
136 $societestatic->client = $objp->client;
137 $societestatic->logo = $objp->logo;
138 $societestatic->email = $objp->email;
139 $societestatic->entity = $objp->entity;
142 if ($objp->status == 1 && $dateterm < ($now -
$conf->propal->cloture->warning_delay)) {
146 $this->info_box_contents[$line][] = array(
147 'td' =>
'class="nowraponall"',
148 'text' => $propalstatic->getNomUrl(1),
153 $this->info_box_contents[$line][] = array(
154 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
155 'text' => $societestatic->getNomUrl(1),
159 $this->info_box_contents[$line][] = array(
160 'td' =>
'class="nowraponall right amount"',
161 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency),
164 $this->info_box_contents[$line][] = array(
169 $this->info_box_contents[$line][] = array(
170 'td' =>
'class="right" width="18"',
171 'text' => $propalstatic->LibStatut($objp->status, 3),
178 $this->db->free($result);
180 $this->info_box_contents[0][0] = array(
183 'text' => ($this->db->error().
' sql='.$sql),
187 $this->info_box_contents[0][0] = array(
188 'td' =>
'class="nohover left"',
189 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'