add status and status_buy

This commit is contained in:
Frédéric FRANCE 2021-01-19 18:01:30 +01:00
parent 01996261dc
commit 84985c5065
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
2 changed files with 21 additions and 26 deletions

View File

@ -4334,6 +4334,7 @@ class Product extends CommonObject
public function getFather() public function getFather()
{ {
$sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec, p.entity"; $sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec, p.entity";
$sql .= ", p.tosell as status, p.tobuy as status_buy";
$sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa,";
$sql .= " ".MAIN_DB_PREFIX."product as p"; $sql .= " ".MAIN_DB_PREFIX."product as p";
$sql .= " WHERE p.rowid = pa.fk_product_pere"; $sql .= " WHERE p.rowid = pa.fk_product_pere";
@ -4342,8 +4343,7 @@ class Product extends CommonObject
$res = $this->db->query($sql); $res = $this->db->query($sql);
if ($res) { if ($res) {
$prods = array(); $prods = array();
while ($record = $this->db->fetch_array($res)) while ($record = $this->db->fetch_array($res)) {
{
// $record['id'] = $record['rowid'] = id of father // $record['id'] = $record['rowid'] = id of father
$prods[$record['id']]['id'] = $record['rowid']; $prods[$record['id']]['id'] = $record['rowid'];
$prods[$record['id']]['ref'] = $record['ref']; $prods[$record['id']]['ref'] = $record['ref'];
@ -4352,6 +4352,8 @@ class Product extends CommonObject
$prods[$record['id']]['incdec'] = $record['incdec']; $prods[$record['id']]['incdec'] = $record['incdec'];
$prods[$record['id']]['fk_product_type'] = $record['fk_product_type']; $prods[$record['id']]['fk_product_type'] = $record['fk_product_type'];
$prods[$record['id']]['entity'] = $record['entity']; $prods[$record['id']]['entity'] = $record['entity'];
$prods[$record['id']]['status'] = $record['status'];
$prods[$record['id']]['status_buy'] = $record['status_buy'];
} }
return $prods; return $prods;
} else { } else {

View File

@ -138,18 +138,17 @@ if ($action == 'search')
$sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type as type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type as type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,';
$sql .= ' p.fk_product_type, p.tms as datem, p.tobatch'; $sql .= ' p.fk_product_type, p.tms as datem, p.tobatch';
$sql .= ', p.tosell as status, p.tobuy as status_buy';
if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ', pl.label as labelm, pl.description as descriptionm'; if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ', pl.label as labelm, pl.description as descriptionm';
$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON p.rowid = cp.fk_product';
if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'"; if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND lang='".($current_lang)."'";
$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($key != "") if ($key != "") {
{
// For natural search // For natural search
$params = array('p.ref', 'p.label', 'p.description', 'p.note'); $params = array('p.ref', 'p.label', 'p.description', 'p.note');
// multilang // multilang
if (!empty($conf->global->MAIN_MULTILANGS)) if (!empty($conf->global->MAIN_MULTILANGS)) {
{
$params[] = 'pl.label'; $params[] = 'pl.label';
$params[] = 'pl.description'; $params[] = 'pl.description';
$params[] = 'pl.note'; $params[] = 'pl.note';
@ -159,8 +158,7 @@ if ($action == 'search')
} }
$sql .= natural_search($params, $key); $sql .= natural_search($params, $key);
} }
if (!empty($conf->categorie->enabled) && !empty($parent) && $parent != -1) if (!empty($conf->categorie->enabled) && !empty($parent) && $parent != -1) {
{
$sql .= " AND cp.fk_categorie ='".$db->escape($parent)."'"; $sql .= " AND cp.fk_categorie ='".$db->escape($parent)."'";
} }
$sql .= " ORDER BY p.ref ASC"; $sql .= " ORDER BY p.ref ASC";
@ -171,13 +169,11 @@ if ($action == 'search')
$title = $langs->trans('ProductServiceCard'); $title = $langs->trans('ProductServiceCard');
$helpurl = ''; $helpurl = '';
$shortlabel = dol_trunc($object->label, 16); $shortlabel = dol_trunc($object->label, 16);
if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
{
$title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('AssociatedProducts'); $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('AssociatedProducts');
$helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
} }
if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
{
$title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('AssociatedProducts'); $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('AssociatedProducts');
$helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
} }
@ -269,16 +265,16 @@ if ($id > 0 || !empty($ref))
print '<td>'.$langs->trans('Label').'</td>'; print '<td>'.$langs->trans('Label').'</td>';
print '<td>'.$langs->trans('Qty').'</td>'; print '<td>'.$langs->trans('Qty').'</td>';
print '</td>'; print '</td>';
if (count($prodsfather) > 0) if (count($prodsfather) > 0) {
{ foreach ($prodsfather as $value) {
foreach ($prodsfather as $value)
{
$idprod = $value["id"]; $idprod = $value["id"];
$productstatic->id = $idprod; // $value["id"]; $productstatic->id = $idprod; // $value["id"];
$productstatic->type = $value["fk_product_type"]; $productstatic->type = $value["fk_product_type"];
$productstatic->ref = $value['ref']; $productstatic->ref = $value['ref'];
$productstatic->label = $value['label']; $productstatic->label = $value['label'];
$productstatic->entity = $value['entity']; $productstatic->entity = $value['entity'];
$productstatic->status = $value['status'];
$productstatic->status_buy = $value['status_buy'];
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$productstatic->getNomUrl(1, 'composition').'</td>'; print '<td>'.$productstatic->getNomUrl(1, 'composition').'</td>';
@ -532,24 +528,19 @@ if ($id > 0 || !empty($ref))
$prod_arbo = new Product($db); $prod_arbo = new Product($db);
$prod_arbo->id = $objp->rowid; $prod_arbo->id = $objp->rowid;
// This type is not supported (not required to have virtual products working). // This type is not supported (not required to have virtual products working).
if ($prod_arbo->type == Product::TYPE_ASSEMBLYKIT || $prod_arbo->type == Product::TYPE_STOCKKIT) if ($prod_arbo->type == Product::TYPE_ASSEMBLYKIT || $prod_arbo->type == Product::TYPE_STOCKKIT) {
{
$is_pere = 0; $is_pere = 0;
$prod_arbo->get_sousproduits_arbo(); $prod_arbo->get_sousproduits_arbo();
// associations sousproduits // associations sousproduits
$prods_arbo = $prod_arbo->get_arbo_each_prod(); $prods_arbo = $prod_arbo->get_arbo_each_prod();
if (count($prods_arbo) > 0) if (count($prods_arbo) > 0) {
{ foreach ($prods_arbo as $key => $value) {
foreach ($prods_arbo as $key => $value) if ($value[1] == $id) {
{
if ($value[1] == $id)
{
$is_pere = 1; $is_pere = 1;
} }
} }
} }
if ($is_pere == 1) if ($is_pere == 1) {
{
$i++; $i++;
continue; continue;
} }
@ -563,6 +554,8 @@ if ($id > 0 || !empty($ref))
$productstatic->label = $objp->label; $productstatic->label = $objp->label;
$productstatic->type = $objp->type; $productstatic->type = $objp->type;
$productstatic->entity = $objp->entity; $productstatic->entity = $objp->entity;
$productstatic->status = $objp->status;
$productstatic->status_buy = $objp->status_buy;
$productstatic->status_batch = $objp->tobatch; $productstatic->status_batch = $objp->tobatch;
print '<td>'.$productstatic->getNomUrl(1, '', 24).'</td>'; print '<td>'.$productstatic->getNomUrl(1, '', 24).'</td>';