27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 var $boxcode=
"lastpropals";
36 var $boximg=
"object_propal";
37 var $boxlabel=
"BoxLastProposals";
38 var $depends = array(
"propal");
47 var $info_box_head = array();
48 var $info_box_contents = array();
63 $this->hidden=! ($user->rights->propale->lire);
74 global $user, $langs, $db, $conf;
78 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
79 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
80 $propalstatic=
new Propal($db);
81 $societestatic =
new Societe($db);
83 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLast".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE?
"":
"Modified").
"Propals",$max));
85 if ($user->rights->propale->lire)
87 $sql =
"SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,";
88 $sql.=
" p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms";
89 $sql.=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
90 $sql.=
", ".MAIN_DB_PREFIX.
"propal as p";
91 if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
92 $sql.=
" WHERE p.fk_soc = s.rowid";
93 $sql.=
" AND p.entity = ".$conf->entity;
94 if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.=
" AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
95 if($user->societe_id) $sql.=
" AND s.rowid = ".$user->societe_id;
96 if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql.=
" ORDER BY p.datep DESC, p.ref DESC ";
97 else $sql.=
" ORDER BY p.tms DESC, p.ref DESC ";
98 $sql.= $db->plimit($max, 0);
100 $result = $db->query($sql);
103 $num = $db->num_rows($result);
108 while ($line < $num) {
109 $objp = $db->fetch_object($result);
110 $date=$db->jdate($objp->dp);
111 $datec=$db->jdate($objp->datec);
112 $datem=$db->jdate($objp->tms);
113 $dateterm=$db->jdate($objp->fin_validite);
114 $dateclose=$db->jdate($objp->date_cloture);
115 $propalstatic->id = $objp->rowid;
116 $propalstatic->ref = $objp->ref;
117 $propalstatic->total_ht = $objp->total_ht;
118 $propalstatic->total_tva = $objp->total_tva;
119 $propalstatic->total_ttc = $objp->total_ttc;
120 $societestatic->id = $objp->socid;
121 $societestatic->name = $objp->name;
122 $societestatic->code_client = $objp->code_client;
123 $societestatic->logo = $objp->logo;
126 if ($objp->fk_statut == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) {
130 $this->info_box_contents[$line][] = array(
132 'text' => $propalstatic->getNomUrl(1),
137 $this->info_box_contents[$line][] = array(
138 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
139 'text' => $societestatic->getNomUrl(1),
143 $this->info_box_contents[$line][] = array(
144 'td' =>
'class="right nowraponall"',
145 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
148 $this->info_box_contents[$line][] = array(
149 'td' =>
'class="right"',
153 $this->info_box_contents[$line][] = array(
154 'td' =>
'align="right" width="18"',
155 'text' => $propalstatic->LibStatut($objp->fk_statut,3),
162 $this->info_box_contents[$line][0] = array(
163 'td' =>
'align="center"',
164 'text'=>$langs->trans(
"NoRecordedProposals"),
169 $this->info_box_contents[0][0] = array(
172 'text' => ($db->error().
' sql='.$sql),
176 $this->info_box_contents[0][0] = array(
177 'td' =>
'align="left" class="nohover opacitymedium"',
178 'text' => $langs->trans(
"ReadPermissionNotAllowed")
191 function showBox($head = null, $contents = null, $nooutput=0)
193 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
img_warning($titlealt='default', $moreatt='')
Show warning logo.
Class to manage the box to show last proposals.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_now($mode='gmt')
Return date for now.
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...
dol_print_date($time, $format='', $tzoutput='tzserver', $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.