27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastmos";
36 public $boximg =
"object_mrp";
37 public $boxlabel =
"BoxTitleLatestModifiedMos";
38 public $depends = array(
"mrp");
47 public $info_box_head = array();
48 public $info_box_contents = array();
63 $this->hidden = !($user->rights->bom->read);
74 global $user, $langs, $conf;
78 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
79 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
81 $mostatic =
new Mo($this->
db);
83 $userstatic =
new User($this->
db);
85 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLatestModifiedMos", $max));
87 if ($user->rights->mrp->read)
89 $sql =
"SELECT p.ref as product_ref";
91 $sql .=
", c.date_creation";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
97 $sql .=
", ".MAIN_DB_PREFIX.
"mrp_mo as c";
98 $sql .=
" WHERE c.fk_product = p.rowid";
99 $sql .=
" AND c.entity = ".$conf->entity;
100 $sql .=
" ORDER BY c.tms DESC, c.ref DESC";
101 $sql .=
" ".$this->db->plimit($max, 0);
103 $result = $this->
db->query($sql);
105 $num = $this->
db->num_rows($result);
109 while ($line < $num) {
110 $objp = $this->
db->fetch_object($result);
111 $datem = $this->
db->jdate($objp->tms);
112 $mostatic->id = $objp->rowid;
113 $mostatic->ref = $objp->ref;
114 $mostatic->id = $objp->socid;
115 $mostatic->status = $objp->status;
116 $productstatic->ref = $objp->product_ref;
118 $this->info_box_contents[$line][] = array(
119 'td' =>
'class="nowraponall"',
120 'text' => $mostatic->getNomUrl(1),
124 $this->info_box_contents[$line][] = array(
125 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
126 'text' => $productstatic->getNomUrl(1),
130 if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) {
131 if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
132 $this->info_box_contents[$line][] = array(
133 'td' =>
'class="right"',
134 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) :
''),
139 $this->info_box_contents[$line][] = array(
140 'td' =>
'class="right"',
144 $this->info_box_contents[$line][] = array(
145 'td' =>
'class="right" width="18"',
146 'text' => $mostatic->LibStatut($objp->status, 3),
152 if ($num == 0) $this->info_box_contents[$line][0] = array(
153 'td' =>
'class="center"',
154 'text'=>
'<span class="opacitymedium">'.$langs->trans(
"NoRecordedOrders").
'</span>'
157 $this->
db->free($result);
159 $this->info_box_contents[0][0] = array(
162 'text' => ($this->
db->error().
' sql='.$sql),
166 $this->info_box_contents[0][0] = array(
167 'td' =>
'class="nohover left"',
168 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'
181 public function showBox($head = null, $contents = null, $nooutput = 0)
183 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage the box to show last orders.
Class to manage products or services.
Class to manage Dolibarr users.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
$conf db
API class for accounts.
loadBox($max=5)
Load data for box to show them later.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
__construct($db, $param)
Constructor.