66 global $user, $langs,
$conf;
70 include_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
71 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
73 $bomstatic =
new BOM($this->db);
74 $productstatic =
new Product($this->db);
75 $userstatic =
new User($this->db);
77 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLatestModifiedBoms", $max));
79 if ($user->hasRight(
'bom',
'read')) {
80 $sql =
"SELECT p.ref as product_ref";
81 $sql .=
", p.rowid as productid";
84 $sql .=
", p.tobatch";
86 $sql .=
", c.date_creation";
90 $sql .=
", c.fk_user_valid";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
92 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom as c";
93 $sql .=
" WHERE c.fk_product = p.rowid";
94 $sql .=
" AND c.entity = ".$conf->entity;
95 $sql .=
" ORDER BY c.tms DESC, c.ref DESC";
96 $sql .= $this->db->plimit($max, 0);
98 $result = $this->db->query($sql);
100 $num = $this->db->num_rows($result);
104 while ($line < $num) {
105 $objp = $this->db->fetch_object($result);
106 $datem = $this->db->jdate($objp->tms);
108 $bomstatic->id = $objp->rowid;
109 $bomstatic->ref = $objp->ref;
110 $bomstatic->status = $objp->status;
112 $productstatic->id = $objp->productid;
113 $productstatic->ref = $objp->product_ref;
114 $productstatic->status = $objp->tosell;
115 $productstatic->status_buy = $objp->tobuy;
116 $productstatic->status_batch = $objp->tobatch;
118 $this->info_box_contents[$line][] = array(
119 'td' =>
'class="nowraponall"',
120 'text' => $bomstatic->getNomUrl(1),
124 $this->info_box_contents[$line][] = array(
125 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
126 'text' => $productstatic->getNomUrl(1),
131 if ($objp->fk_user_valid > 0) {
132 $userstatic->fetch($objp->fk_user_valid);
134 $this->info_box_contents[$line][] = array(
135 'td' =>
'class="right"',
136 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) :
''),
141 $this->info_box_contents[$line][] = array(
146 $this->info_box_contents[$line][] = array(
147 'td' =>
'class="right" width="18"',
148 'text' => $bomstatic->LibStatut($objp->status, 3),
161 $this->db->free($result);
163 $this->info_box_contents[0][0] = array(
166 'text' => ($this->db->error().
' sql='.$sql),
170 $this->info_box_contents[0][0] = array(
171 'td' =>
'class="nohover left"',
172 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'