27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"lastboms";
36 public $boximg =
"object_bom";
37 public $boxlabel =
"BoxTitleLatestModifiedBoms";
38 public $depends = array(
"bom");
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.
'/bom/class/bom.class.php';
79 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
81 $bomstatic =
new Bom($this->
db);
83 $userstatic =
new User($this->
db);
85 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleLatestModifiedBoms", $max));
87 if ($user->rights->bom->read)
89 $sql =
"SELECT p.ref as product_ref, p.tobuy, p.tosell";
91 $sql .=
", c.date_creation";
95 $sql .=
", c.fk_user_valid";
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
97 $sql .=
", ".MAIN_DB_PREFIX.
"bom_bom 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);
113 $bomstatic->id = $objp->rowid;
114 $bomstatic->ref = $objp->ref;
115 $bomstatic->id = $objp->socid;
116 $bomstatic->status = $objp->status;
118 $productstatic->ref = $objp->product_ref;
119 $productstatic->status = $objp->tobuy;
120 $productstatic->status_buy = $objp->tosell;
122 $this->info_box_contents[$line][] = array(
123 'td' =>
'class="nowraponall"',
124 'text' => $bomstatic->getNomUrl(1),
128 $this->info_box_contents[$line][] = array(
129 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
130 'text' => $productstatic->getNomUrl(1),
134 if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) {
135 if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="right"',
138 'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) :
''),
143 $this->info_box_contents[$line][] = array(
144 'td' =>
'class="right"',
148 $this->info_box_contents[$line][] = array(
149 'td' =>
'class="right" width="18"',
150 'text' => $bomstatic->LibStatut($objp->status, 3),
156 if ($num == 0) $this->info_box_contents[$line][0] = array(
157 'td' =>
'class="center opacitymedium"',
158 'text'=>$langs->trans(
"NoRecordedOrders")
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 opacitymedium left"',
172 'text' => $langs->trans(
"ReadPermissionNotAllowed")
185 public function showBox($head = null, $contents = null, $nooutput = 0)
187 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
Class to manage products or services.
__construct($db, $param)
Constructor.
Class to manage Dolibarr users.
$conf db
API class for accounts.
Class to manage the box to show last orders.
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 for box to show them later.