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 = !($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".($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ?
"" :
"Modified").
"Propals", $max));
86 if ($user->rights->propale->lire)
88 $sql =
"SELECT s.rowid as socid, s.nom as name, s.name_alias";
89 $sql .=
", s.code_client, s.code_compta, s.client";
90 $sql .=
", s.logo, s.email, s.entity";
91 $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.tva as total_tva, p.total as total_ttc, p.tms";
92 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
93 $sql .=
", ".MAIN_DB_PREFIX.
"propal as p";
94 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
95 $sql .=
" WHERE p.fk_soc = s.rowid";
96 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
97 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
98 if ($user->socid) $sql .=
" AND s.rowid = ".$user->socid;
99 if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) $sql .=
" ORDER BY p.datep DESC, p.ref DESC ";
100 else $sql .=
" ORDER BY p.tms DESC, p.ref DESC ";
101 $sql .= $this->
db->plimit($max, 0);
103 $result = $this->
db->query($sql);
106 $num = $this->
db->num_rows($result);
111 while ($line < $num) {
112 $objp = $this->
db->fetch_object($result);
113 $date = $this->
db->jdate($objp->dp);
114 $datec = $this->
db->jdate($objp->datec);
115 $datem = $this->
db->jdate($objp->tms);
116 $dateterm = $this->
db->jdate($objp->fin_validite);
117 $dateclose = $this->
db->jdate($objp->date_cloture);
119 $propalstatic->id = $objp->rowid;
120 $propalstatic->ref = $objp->ref;
121 $propalstatic->total_ht = $objp->total_ht;
122 $propalstatic->total_tva = $objp->total_tva;
123 $propalstatic->total_ttc = $objp->total_ttc;
124 $propalstatic->statut = $objp->status;
125 $propalstatic->status = $objp->status;
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->client = $objp->client;
133 $societestatic->logo = $objp->logo;
134 $societestatic->email = $objp->email;
135 $societestatic->entity = $objp->entity;
138 if ($objp->status == 1 && $dateterm < ($now - $conf->propal->cloture->warning_delay)) {
142 $this->info_box_contents[$line][] = array(
143 'td' =>
'class="nowraponall"',
144 'text' => $propalstatic->getNomUrl(1),
149 $this->info_box_contents[$line][] = array(
150 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
151 'text' => $societestatic->getNomUrl(1),
155 $this->info_box_contents[$line][] = array(
156 'td' =>
'class="right nowraponall"',
157 'text' =>
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency),
160 $this->info_box_contents[$line][] = array(
161 'td' =>
'class="right"',
165 $this->info_box_contents[$line][] = array(
166 'td' =>
'class="right" width="18"',
167 'text' => $propalstatic->LibStatut($objp->status, 3),
174 $this->info_box_contents[$line][0] = array(
175 'td' =>
'class="center"',
176 'text'=>$langs->trans(
"NoRecordedProposals"),
179 $this->
db->free($result);
181 $this->info_box_contents[0][0] = array(
184 'text' => ($this->
db->error().
' sql='.$sql),
188 $this->info_box_contents[0][0] = array(
189 'td' =>
'class="nohover opacitymedium left"',
190 'text' => $langs->trans(
"ReadPermissionNotAllowed")
203 public function showBox($head = null, $contents = null, $nooutput = 0)
205 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
dol_now($mode= 'auto')
Return date for now.
Class to manage the box to show last proposals.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
$conf db
API class for accounts.
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.