68 global $user, $langs,
$conf, $hookmanager;
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 (empty($user->socid) && !$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 (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
94 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
97 $parameters = array(
'socid' => $user->socid,
'boxcode' => $this->boxcode);
98 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $propalstatic);
99 if (empty($reshook)) {
101 $sql .=
" AND s.rowid = " . ((int) $user->socid);
104 $sql .= $hookmanager->resPrint;
106 $sql .=
" ORDER BY p.datep DESC, p.ref DESC ";
108 $sql .=
" ORDER BY p.tms DESC, p.ref DESC ";
110 $sql .= $this->db->plimit($max, 0);
112 $result = $this->db->query($sql);
114 $num = $this->db->num_rows($result);
119 while ($line < $num) {
120 $objp = $this->db->fetch_object($result);
121 $date = $this->db->jdate($objp->dp);
122 $datec = $this->db->jdate($objp->datec);
123 $datem = $this->db->jdate($objp->tms);
124 $dateterm = $this->db->jdate($objp->fin_validite);
125 $dateclose = $this->db->jdate($objp->date_cloture);
127 $propalstatic->id = $objp->rowid;
128 $propalstatic->ref = $objp->ref;
129 $propalstatic->total_ht = $objp->total_ht;
130 $propalstatic->total_tva = $objp->total_tva;
131 $propalstatic->total_ttc = $objp->total_ttc;
132 $propalstatic->statut = $objp->status;
133 $propalstatic->status = $objp->status;
134 $propalstatic->date = $date;
136 $societestatic->id = $objp->socid;
137 $societestatic->name = $objp->name;
139 $societestatic->code_client = $objp->code_client;
140 $societestatic->code_compta = $objp->code_compta;
141 $societestatic->code_compta_client = $objp->code_compta;
142 $societestatic->client = $objp->client;
143 $societestatic->logo = $objp->logo;
144 $societestatic->email = $objp->email;
145 $societestatic->entity = $objp->entity;
148 if ($objp->status == 1 && $dateterm < ($now -
$conf->propal->cloture->warning_delay)) {
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="nowraponall"',
154 'text' => $propalstatic->getNomUrl(1),
159 $this->info_box_contents[$line][] = array(
160 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
161 'text' => $societestatic->getNomUrl(1),
165 $this->info_box_contents[$line][] = array(
166 'td' =>
'class="nowraponall right amount"',
167 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency),
170 $this->info_box_contents[$line][] = array(
175 $this->info_box_contents[$line][] = array(
176 'td' =>
'class="right" width="18"',
177 'text' => $propalstatic->LibStatut($objp->status, 3),
184 $this->db->free($result);
186 $this->info_box_contents[0][0] = array(
189 'text' => ($this->db->error().
' sql='.$sql),
193 $this->info_box_contents[0][0] = array(
194 'td' =>
'class="nohover left"',
195 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'