63 global $user, $langs, $conf;
67 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
68 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
70 $mostatic =
new Mo($this->db);
71 $productstatic =
new Product($this->db);
72 $userstatic =
new User($this->db);
74 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLatestModifiedMos", $max));
76 if ($user->hasRight(
'mrp',
'read')) {
77 $sql =
"SELECT p.ref as product_ref";
78 $sql .=
", p.rowid as productid";
81 $sql .=
", p.tobatch";
83 $sql .=
", c.date_creation";
87 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
88 $sql .=
", ".MAIN_DB_PREFIX.
"mrp_mo as c";
89 $sql .=
" WHERE c.fk_product = p.rowid";
90 $sql .=
" AND c.entity = ".$conf->entity;
91 $sql .=
" ORDER BY c.tms DESC, c.ref DESC";
92 $sql .= $this->db->plimit($max, 0);
94 $result = $this->db->query($sql);
96 $num = $this->db->num_rows($result);
100 while ($line < $num) {
101 $objp = $this->db->fetch_object($result);
102 $datem = $this->db->jdate($objp->tms);
103 $mostatic->id = $objp->rowid;
104 $mostatic->ref = $objp->ref;
105 $mostatic->status = $objp->status;
106 $productstatic->id = $objp->productid;
107 $productstatic->ref = $objp->product_ref;
108 $productstatic->status = $objp->tosell;
109 $productstatic->status_buy = $objp->tobuy;
110 $productstatic->status_batch = $objp->tobatch;
112 $this->info_box_contents[$line][] = array(
113 'td' =>
'class="nowraponall"',
114 'text' => $mostatic->getNomUrl(1),
118 $this->info_box_contents[$line][] = array(
119 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
120 'text' => $productstatic->getNomUrl(1),
125 if ($objp->fk_user_valid > 0) {
126 $userstatic->fetch($objp->fk_user_valid);
128 $this->info_box_contents[$line][] = array(
129 'td' =>
'class="right"',
130 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) :
''),
135 $this->info_box_contents[$line][] = array(
140 $this->info_box_contents[$line][] = array(
141 'td' =>
'class="right" width="18"',
142 'text' => $mostatic->LibStatut($objp->status, 3),
149 $this->info_box_contents[$line][0] = array(
150 'td' =>
'class="center"',
151 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedOrders").
'</span>'
155 $this->db->free($result);
157 $this->info_box_contents[0][0] = array(
160 'text' => ($this->db->error().
' sql='.$sql),
164 $this->info_box_contents[0][0] = array(
165 'td' =>
'class="nohover left"',
166 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'