28 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
36 public $boxcode =
"lastpropals";
37 public $boximg =
"object_propal";
38 public $boxlabel =
"BoxLastProposals";
39 public $depends = array(
"propal");
48 public $info_box_head = array();
49 public $info_box_contents = array();
64 $this->hidden = empty($user->rights->propale->lire);
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);
84 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ?
"" :
"Modified").
"Propals", $max));
86 if ($user->rights->propale->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.
"societe as s";
92 $sql .=
", ".MAIN_DB_PREFIX.
"propal as p";
93 if (empty($user->rights->societe->client->voir) && !$user->socid) {
94 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
96 $sql .=
" WHERE p.fk_soc = s.rowid";
97 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
98 if (empty($user->rights->societe->client->voir) && !$user->socid) {
99 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
102 $sql .=
" AND s.rowid = ".((int) $user->socid);
104 if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
105 $sql .=
" ORDER BY p.datep DESC, p.ref DESC ";
107 $sql .=
" ORDER BY p.tms DESC, p.ref DESC ";
109 $sql .= $this->
db->plimit($max, 0);
111 $result = $this->
db->query($sql);
113 $num = $this->
db->num_rows($result);
118 while ($line < $num) {
119 $objp = $this->
db->fetch_object($result);
120 $date = $this->
db->jdate($objp->dp);
121 $datec = $this->
db->jdate($objp->datec);
122 $datem = $this->
db->jdate($objp->tms);
123 $dateterm = $this->
db->jdate($objp->fin_validite);
124 $dateclose = $this->
db->jdate($objp->date_cloture);
126 $propalstatic->id = $objp->rowid;
127 $propalstatic->ref = $objp->ref;
128 $propalstatic->total_ht = $objp->total_ht;
129 $propalstatic->total_tva = $objp->total_tva;
130 $propalstatic->total_ttc = $objp->total_ttc;
131 $propalstatic->statut = $objp->status;
132 $propalstatic->status = $objp->status;
133 $propalstatic->date = $date;
135 $societestatic->id = $objp->socid;
136 $societestatic->name = $objp->name;
138 $societestatic->code_client = $objp->code_client;
139 $societestatic->code_compta = $objp->code_compta;
140 $societestatic->client = $objp->client;
141 $societestatic->logo = $objp->logo;
142 $societestatic->email = $objp->email;
143 $societestatic->entity = $objp->entity;
146 if ($objp->status == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) {
150 $this->info_box_contents[$line][] = array(
151 'td' =>
'class="nowraponall"',
152 'text' => $propalstatic->getNomUrl(1),
157 $this->info_box_contents[$line][] = array(
158 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
159 'text' => $societestatic->getNomUrl(1),
163 $this->info_box_contents[$line][] = array(
164 'td' =>
'class="nowraponall right amount"',
165 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
168 $this->info_box_contents[$line][] = array(
173 $this->info_box_contents[$line][] = array(
174 'td' =>
'class="right" width="18"',
175 'text' => $propalstatic->LibStatut($objp->status, 3),
182 $this->info_box_contents[$line][0] = array(
183 'td' =>
'class="center"',
184 'text'=>$langs->trans(
"NoRecordedProposals"),
188 $this->
db->free($result);
190 $this->info_box_contents[0][0] = array(
193 'text' => ($this->
db->error().
' sql='.$sql),
197 $this->info_box_contents[0][0] = array(
198 'td' =>
'class="nohover opacitymedium left"',
199 'text' => $langs->trans(
"ReadPermissionNotAllowed")
212 public function showBox($head = null, $contents = null, $nooutput = 0)
214 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
$conf db
API class for accounts.
dol_now($mode= 'auto')
Return date for now.
Class to manage the box to show last proposals.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
Class to manage third parties objects (customers, suppliers, prospects...)
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
loadBox($max=5)
Load data into info_box_contents array to show array later.
__construct($db, $param)
Constructor.
Class to manage proposals.