/**
 * Get produt or service
 *
 * @param	array		$authentication		Array of authentication information
 * @param	int			$id					Id of object
 * @param	string		$ref				Ref of object
 * @param	string		$ref_ext			Ref external of object
 * @param   string      $lang               Lang to force
 * @return	mixed
 */
function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '', $lang = '')
{
    global $db, $conf, $langs;
    dol_syslog("Function: getProductOrService login="******" id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext);
    $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
    $langs->setDefaultLang($langcode);
    if ($authentication['entity']) {
        $conf->entity = $authentication['entity'];
    }
    // Init and check authentication
    $objectresp = array();
    $errorcode = '';
    $errorlabel = '';
    $error = 0;
    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
    // Check parameters
    if (!$error && ($id && $ref || $id && $ref_ext || $ref && $ref_ext)) {
        $error++;
        $errorcode = 'BAD_PARAMETERS';
        $errorlabel = "Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
    }
    if (!$error) {
        $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
        $langs->setDefaultLang($langcode);
        $fuser->getrights();
        if ($fuser->rights->produit->lire || $fuser->rights->service->lire) {
            $product = new Product($db);
            $result = $product->fetch($id, $ref, $ref_ext);
            if ($result > 0) {
                $product->load_stock();
                $dir = !empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output;
                $pdir = get_exdir($product->id, 2) . $product->id . "/photos/";
                $dir = $dir . '/' . $pdir;
                if (!empty($product->multilangs[$langs->defaultlang]["label"])) {
                    $product->label = $product->multilangs[$langs->defaultlang]["label"];
                }
                if (!empty($product->multilangs[$langs->defaultlang]["description"])) {
                    $product->description = $product->multilangs[$langs->defaultlang]["description"];
                }
                if (!empty($product->multilangs[$langs->defaultlang]["note"])) {
                    $product->note = $product->multilangs[$langs->defaultlang]["note"];
                }
                $productorservice_result_fields = array('id' => $product->id, 'ref' => $product->ref, 'ref_ext' => $product->ref_ext, 'label' => $product->label, 'description' => $product->description, 'date_creation' => dol_print_date($product->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($product->date_modification, 'dayhourrfc'), 'note' => $product->note, 'status_tosell' => $product->status, 'status_tobuy' => $product->status_buy, 'type' => $product->type, 'barcode' => $product->barcode, 'barcode_type' => $product->barcode_type, 'country_id' => $product->country_id > 0 ? $product->country_id : '', 'country_code' => $product->country_code, 'custom_code' => $product->customcode, 'price_net' => $product->price, 'price' => $product->price_ttc, 'price_min_net' => $product->price_min, 'price_min' => $product->price_min_ttc, 'price_base_type' => $product->price_base_type, 'vat_rate' => $product->tva_tx, 'vat_npr' => $product->tva_npr, 'localtax1_tx' => $product->localtax1_tx, 'localtax2_tx' => $product->localtax2_tx, 'stock_real' => $product->stock_reel, 'stock_alert' => $product->seuil_stock_alerte, 'pmp' => $product->pmp, 'import_key' => $product->import_key, 'dir' => $pdir, 'images' => $product->liste_photos($dir, $nbmax = 10));
                //Retreive all extrafield for thirdsparty
                // fetch optionals attributes and labels
                $extrafields = new ExtraFields($db);
                $extralabels = $extrafields->fetch_name_optionals_label('product', true);
                //Get extrafield values
                $product->fetch_optionals($product->id, $extralabels);
                foreach ($extrafields->attribute_label as $key => $label) {
                    $productorservice_result_fields = array_merge($productorservice_result_fields, array('options_' . $key => $product->array_options['options_' . $key]));
                }
                // Create
                $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'product' => $productorservice_result_fields);
            } else {
                $error++;
                $errorcode = 'NOT_FOUND';
                $errorlabel = 'Object not found for id=' . $id . ' nor ref=' . $ref . ' nor ref_ext=' . $ref_ext;
            }
        } else {
            $error++;
            $errorcode = 'PERMISSION_DENIED';
            $errorlabel = 'User does not have permission for this request';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    //var_dump($objectresp);exit;
    return $objectresp;
}
/**
 * Get list of products for a category
 *
 * @param	array		$authentication		Array of authentication information
 * @param	array		$id					Category id
 * @param	$lang		$lang				Force lang
 * @return	array							Array result
 */
function getProductsForCategory($authentication, $id, $lang = '')
{
    global $db, $conf, $langs;
    $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
    $langs->setDefaultLang($langcode);
    dol_syslog("Function: getProductsForCategory login="******" id=" . $id);
    if ($authentication['entity']) {
        $conf->entity = $authentication['entity'];
    }
    $objectresp = array();
    $errorcode = '';
    $errorlabel = '';
    $error = 0;
    $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel);
    if (!$error && !$id) {
        $error++;
        $errorcode = 'BAD_PARAMETERS';
        $errorlabel = "Parameter id must be provided.";
    }
    if (!$error) {
        $langcode = $lang ? $lang : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT);
        $langs->setDefaultLang($langcode);
        $fuser->getrights();
        if ($fuser->rights->produit->lire) {
            $categorie = new Categorie($db);
            $result = $categorie->fetch($id);
            if ($result > 0) {
                $table = "product";
                $field = "product";
                $sql = "SELECT fk_" . $field . " FROM " . MAIN_DB_PREFIX . "categorie_" . $table;
                $sql .= " WHERE fk_categorie = " . $id;
                $sql .= " ORDER BY fk_" . $field . " ASC";
                dol_syslog("getProductsForCategory get id of product into category", LOG_DEBUG);
                $res = $db->query($sql);
                if ($res) {
                    while ($rec = $db->fetch_array($res)) {
                        $obj = new Product($db);
                        $obj->fetch($rec['fk_' . $field]);
                        $iProduct = 0;
                        if ($obj->status > 0) {
                            $dir = !empty($conf->product->dir_output) ? $conf->product->dir_output : $conf->service->dir_output;
                            $pdir = get_exdir($obj->id, 2, 0, 0, $product, 'product') . $obj->id . "/photos/";
                            $dir = $dir . '/' . $pdir;
                            $products[] = array('id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, 'label' => !empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, 'description' => !empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, 'date_creation' => dol_print_date($obj->date_creation, 'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification, 'dayhourrfc'), 'note' => !empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, 'barcode' => $obj->barcode, 'barcode_type' => $obj->barcode_type, 'country_id' => $obj->country_id > 0 ? $obj->country_id : '', 'country_code' => $obj->country_code, 'custom_code' => $obj->customcode, 'price_net' => $obj->price, 'price' => $obj->price_ttc, 'vat_rate' => $obj->tva_tx, 'price_base_type' => $obj->price_base_type, 'stock_real' => $obj->stock_reel, 'stock_alert' => $obj->seuil_stock_alerte, 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, 'images' => $obj->liste_photos($dir, $nbmax = 10));
                            //Retreive all extrafield for thirdsparty
                            // fetch optionals attributes and labels
                            $extrafields = new ExtraFields($db);
                            $extralabels = $extrafields->fetch_name_optionals_label('product', true);
                            //Get extrafield values
                            $obj->fetch_optionals($obj->id, $extralabels);
                            foreach ($extrafields->attribute_label as $key => $label) {
                                $products[$iProduct] = array_merge($products[$iProduct], array('options_' . $key => $obj->array_options['options_' . $key]));
                            }
                            $iProduct++;
                        }
                    }
                    // Retour
                    $objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'products' => $products);
                } else {
                    $errorcode = 'NORECORDS_FOR_ASSOCIATION';
                    $errorlabel = 'No products associated' . $sql;
                    $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
                    dol_syslog("getProductsForCategory:: " . $c->error, LOG_DEBUG);
                }
            } else {
                $error++;
                $errorcode = 'NOT_FOUND';
                $errorlabel = 'Object not found for id=' . $id;
            }
        } else {
            $error++;
            $errorcode = 'PERMISSION_DENIED';
            $errorlabel = 'User does not have permission for this request';
        }
    }
    if ($error) {
        $objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
    }
    return $objectresp;
}
Example #3
0
 /**
  *	Calculates price based on expression
  *
  *	@param	Product	$product    	The Product object to get information
  *	@param	String 	$expression     The expression to parse
  *	@param	array  	$values     	Strings to replaces
  *  @return int 					> 0 if OK, < 1 if KO
  */
 public function parseExpression($product, $expression, $values)
 {
     global $user;
     //Accessible product values by expressions
     $values = array_merge($values, array("tva_tx" => $product->tva_tx, "localtax1_tx" => $product->localtax1_tx, "localtax2_tx" => $product->localtax2_tx, "weight" => $product->weight, "length" => $product->length, "surface" => $product->surface, "price_min" => $product->price_min));
     //Retrieve all extrafield for product and add it to values
     $extrafields = new ExtraFields($this->db);
     $extralabels = $extrafields->fetch_name_optionals_label('product', true);
     $product->fetch_optionals($product->id, $extralabels);
     foreach ($extrafields->attribute_label as $key => $label) {
         $values["extrafield_" . $key] = $product->array_options['options_' . $key];
     }
     //Process any pending updaters
     $price_updaters = new PriceGlobalVariableUpdater($this->db);
     foreach ($price_updaters->listPendingUpdaters() as $entry) {
         //Schedule the next update by adding current timestamp (secs) + interval (mins)
         $entry->update_next_update(dol_now() + $entry->update_interval * 60, $user);
         //Do processing
         $res = $entry->process();
         //Store any error or clear status if OK
         $entry->update_status($res < 1 ? $entry->error : '', $user);
     }
     //Get all global values
     $price_globals = new PriceGlobalVariable($this->db);
     foreach ($price_globals->listGlobalVariables() as $entry) {
         $values["global_" . $entry->code] = $entry->value;
     }
     //Check if empty
     $expression = trim($expression);
     if (empty($expression)) {
         $this->error = array(20, null);
         return -2;
     }
     //Prepare the lib, parameters and values
     $em = new EvalMath();
     $em->suppress_errors = true;
     //Don't print errors on page
     $this->error_expr = null;
     $last_result = null;
     //Iterate over each expression splitted by $separator_chr
     $expression = str_replace("\n", $this->separator_chr, $expression);
     foreach ($values as $key => $value) {
         $expression = str_replace($this->special_chr . $key . $this->special_chr, "{$value}", $expression);
     }
     $expressions = explode($this->separator_chr, $expression);
     $expressions = array_slice($expressions, 0, $this->limit);
     foreach ($expressions as $expr) {
         $expr = trim($expr);
         if (!empty($expr)) {
             $last_result = $em->evaluate($expr);
             $this->error = $em->last_error_code;
             if ($this->error !== null) {
                 //$em->last_error is null if no error happened, so just check if error is not null
                 $this->error_expr = $expr;
                 return -3;
             }
         }
     }
     $vars = $em->vars();
     if (empty($vars["price"])) {
         $vars["price"] = $last_result;
     }
     if (!isset($vars["price"])) {
         $this->error = array(21, $expression);
         return -4;
     }
     if ($vars["price"] < 0) {
         $this->error = array(22, $expression);
         return -5;
     }
     return $vars["price"];
 }
function _fiche_ligne(&$form, &$of, $type)
{
    global $db, $conf, $langs, $hookmanager;
    //TODO rules guys ! To Facto ! AA
    $formProduct = new FormProduct($db);
    $PDOdb = new TPDOdb();
    $TRes = array();
    foreach ($of->TAssetOFLine as $k => &$TAssetOFLine) {
        $product =& $TAssetOFLine->product;
        if (is_null($product)) {
            $product = new Product($db);
            $product->fetch($TAssetOFLine->fk_product);
            $product->fetch_optionals();
        }
        $conditionnement = $TAssetOFLine->conditionnement;
        if (!empty($conf->asset->enabled)) {
            $TAssetType = new TAsset_type();
            $TAssetType->load($PDOdb, $product->array_options['options_type_asset']);
            $conditionnement_unit = $TAssetType->measuring_units == 'unit' || $TAssetType->gestion_stock == 'UNIT' ? 'unité(s)' : $TAssetOFLine->libUnite();
        } else {
            $conditionnement_unit = 'unité(s)';
            // TODO translate
        }
        //$conditionnement_unit = $TAssetOFLine->libUnite();
        if ($TAssetOFLine->measuring_units != 'unit' && !empty($TAssetOFLine->measuring_units)) {
            $conditionnement_label = ' / ' . $conditionnement . " " . $conditionnement_unit;
            $conditionnement_label_edit = ' par ' . $form->texte('', 'TAssetOFLine[' . $k . '][conditionnement]', $conditionnement, 5, 5, '', '') . $conditionnement_unit;
        } else {
            $conditionnement_label = $conditionnement_label_edit = '';
        }
        if ($TAssetOFLine->type == "NEEDED" && $type == "NEEDED") {
            $stock_needed = TAssetOF::getProductStock($product->id);
            $TLine = array('id' => $TAssetOFLine->getId(), 'idprod' => $form->hidden('TAssetOFLine[' . $k . '][fk_product]', $product->id), 'lot_number' => $of->status == 'DRAFT' ? $form->texte('', 'TAssetOFLine[' . $k . '][lot_number]', $TAssetOFLine->lot_number, 15, 50, 'type_product="NEEDED" fk_product="' . $product->id . '" rel="lot-' . $TAssetOFLine->getId() . '" ', 'TAssetOFLineLot') : $TAssetOFLine->lot_number, 'libelle' => $product->getNomUrl(1) . ' ' . $product->label . ' - ' . ($stock_needed > 0 ? $langs->trans("Stock") . " : " . $stock_needed : '<span style="color:red;font-weight:bold;">' . $langs->trans("Stock") . " : " . $stock_needed . '</span>') . _fiche_ligne_asset($PDOdb, $form, $of, $TAssetOFLine, 'NEEDED'), 'qty_needed' => $TAssetOFLine->qty_needed . $conditionnement_label, 'qty' => $of->status == 'DRAFT' ? $form->texte('', 'TAssetOFLine[' . $k . '][qty]', $TAssetOFLine->qty, 5, 50) : $TAssetOFLine->qty, 'qty_used' => $of->status == 'OPEN' || $of->status == 'CLOSE' ? $form->texte('', 'TAssetOFLine[' . $k . '][qty_used]', $TAssetOFLine->qty_used, 5, 50) : $TAssetOFLine->qty_used, 'qty_toadd' => $TAssetOFLine->qty - $TAssetOFLine->qty_used, 'workstations' => $conf->workstation->enabled ? $TAssetOFLine->visu_checkbox_workstation($db, $of, $form, 'TAssetOFLine[' . $k . '][fk_workstation][]') : '', 'delete' => $form->type_aff == 'edit' && ($of->status == 'DRAFT' || !empty($conf->global->OF_USE_DESTOCKAGE_PARTIEL) && $of->status != 'CLOSE' && empty($TAssetOFLine->qty_used)) ? '<a href="javascript:deleteLine(' . $TAssetOFLine->getId() . ',\'NEEDED\');">' . img_picto('Supprimer', 'delete.png') . '</a>' : '', 'fk_entrepot' => !empty($conf->global->ASSET_MANUAL_WAREHOUSE) && ($of->status == 'DRAFT' || $of->status == 'VALID') && $form->type_aff == 'edit' ? $formProduct->selectWarehouses($TAssetOFLine->fk_entrepot, 'TAssetOFLine[' . $k . '][fk_entrepot]', '', 0, 0, $TAssetOFLine->fk_product) : $TAssetOFLine->getLibelleEntrepot($PDOdb), 'note_private' => $of->status == 'DRAFT' ? $form->zonetexte('', 'TAssetOFLine[' . $k . '][note_private]', $TAssetOFLine->note_private, 50, 1) : $TAssetOFLine->note_private);
            $action = $form->type_aff;
            $parameter = array('of' => &$of, 'line' => &$TLine, 'type' => 'NEEDED');
            $res = $hookmanager->executeHooks('lineObjectOptions', $parameter, $TAssetOFLine, $action);
            if ($res > 0 && !empty($hookmanager->resArray)) {
                $TLine = $hookmanager->resArray;
            }
            $TRes[] = $TLine;
        } elseif ($TAssetOFLine->type == "TO_MAKE" && $type == "TO_MAKE") {
            if (empty($TAssetOFLine->TFournisseurPrice)) {
                $TAssetOFLine->loadFournisseurPrice($PDOdb);
            }
            // Permet de sélectionner par défaut "(Fournisseur "Interne" => Fabrication interne)" si le produit TO_MAKE n'a pas de stock lorsqu'on est en mode edit et que la ligne TO_MAKE n'a pas encore de prix fournisseur enregistré
            dol_include_once('/product/class/product.class.php');
            $p = new Product($db);
            $selected = 0;
            if ($p->fetch($TAssetOFLine->fk_product)) {
                $p->load_stock();
                $p->stock_reel;
                if ($TAssetOFLine->type === 'TO_MAKE' && $p->stock_reel <= 0 && $_REQUEST['action'] === 'edit') {
                    $selected = -2;
                }
            }
            // *************************************************************
            $Tab = array();
            foreach ($TAssetOFLine->TFournisseurPrice as &$objPrice) {
                $label = "";
                //Si on a un prix fournisseur pour le produit
                if ($objPrice->price > 0) {
                    $unit = $objPrice->quantity == 1 ? 'Unité' : 'Unités';
                    $label .= floatval($objPrice->price) . ' ' . $conf->currency . ' - ' . $objPrice->quantity . ' ' . $unit . ' -';
                }
                //Affiche le nom du fournisseur
                $label .= ' (Fournisseur "' . utf8_encode($objPrice->name) . '"';
                //Prix unitaire minimum si renseigné dans le PF
                if ($objPrice->quantity > 0) {
                    ' ' . $objPrice->quantity . ' pièce(s) min,';
                }
                //Affiche le type du PF :
                if ($objPrice->compose_fourni) {
                    //			soit on fabrique les composants
                    $label .= ' => Fabrication interne';
                } elseif ($objPrice->quantity <= 0) {
                    //			soit on a le produit finis déjà en stock
                    $label .= ' => Sortie de stock';
                }
                if ($objPrice->quantity > 0) {
                    //				soit on commande a un fournisseur
                    $label .= ' => Commande fournisseur';
                }
                $label .= ")";
                $Tab[$objPrice->rowid] = array('label' => $label, 'compose_fourni' => $objPrice->compose_fourni ? $objPrice->compose_fourni : 0);
            }
            if ($conf->nomenclature->enabled) {
                dol_include_once('/nomenclature/class/nomenclature.class.php');
                if ($of->status == 'DRAFT' && !$TAssetOFLine->nomenclature_valide) {
                    $TNomenclature = TNomenclature::get($PDOdb, $TAssetOFLine->fk_product, true);
                    if (count($TNomenclature) > 0) {
                        $nomenclature = '<div>' . $form->combo('', 'TAssetOFLine[' . $k . '][fk_nomenclature]', $TNomenclature, $TAssetOFLine->fk_nomenclature);
                        if ($form->type_aff == 'edit') {
                            $nomenclature .= '<a href="#" class="valider_nomenclature" data-id_of="' . $of->getId() . '" data-product="' . $TAssetOFLine->fk_product . '" data-of_line="' . $TAssetOFLine->rowid . '">Valider</a>';
                        } else {
                            $nomenclature .= " - Nomenclature à sélectionner";
                        }
                        $nomenclature .= '</div>';
                    } else {
                        $nomenclature = '';
                    }
                } else {
                    $n = new TNomenclature();
                    $n->load($PDOdb, $TAssetOFLine->fk_nomenclature);
                    $nomenclature = '<div>' . (string) $n;
                    $picture = $TAssetOFLine->nomenclature_valide ? 'ok.png' : 'no.png';
                    $nomenclature .= ' <img src="img/' . $picture . '" style="padding-left: 2px; vertical-align: middle;" /></div>';
                }
            }
            //($of->status=='DRAFT') ? $form->combo('', 'TAssetOFLine['.$k.'][fk_nomenclature]', _getArrayNomenclature($PDOdb, $TAssetOFLine), $TAssetOFLine->fk_nomenclature) : _getTitleNomenclature($PDOdb, $TAssetOFLine->fk_nomenclature)
            $stock_tomake = TAssetOF::getProductStock($product->id);
            $TLine = array('id' => $TAssetOFLine->getId(), 'idprod' => $form->hidden('TAssetOFLine[' . $k . '][fk_product]', $product->id), 'lot_number' => $of->status == 'DRAFT' ? $form->texte('', 'TAssetOFLine[' . $k . '][lot_number]', $TAssetOFLine->lot_number, 15, 50, 'type_product="TO_MAKE" fk_product="' . $product->id . '"', 'TAssetOFLineLot') : $TAssetOFLine->lot_number, 'libelle' => $product->getNomUrl(1) . ' ' . $product->label . ' - ' . $langs->trans("Stock") . " : " . $stock_tomake . _fiche_ligne_asset($PDOdb, $form, $of, $TAssetOFLine, false), 'nomenclature' => $nomenclature, 'addneeded' => $form->type_aff == 'edit' && $of->status == 'DRAFT' ? '<a href="#null" statut="' . $of->status . '" onclick="addAllLines(' . $of->getId() . ',' . $TAssetOFLine->getId() . ',this);">' . img_picto('Mettre à jour les produits nécessaires', 'object_technic.png') . '</a>' : '', 'qty' => $of->status == 'DRAFT' ? $form->texte('', 'TAssetOFLine[' . $k . '][qty]', $TAssetOFLine->qty, 5, 5, '', '') . $conditionnement_label_edit : $TAssetOFLine->qty . $conditionnement_label, 'qty_used' => $of->status == 'OPEN' || $of->status == 'CLOSE' ? $form->texte('', 'TAssetOFLine[' . $k . '][qty_used]', $TAssetOFLine->qty_used, 5, 5, '', '') . $conditionnement_label_edit : $TAssetOFLine->qty_used . $conditionnement_label, 'fk_product_fournisseur_price' => $form->combo('', 'TAssetOFLine[' . $k . '][fk_product_fournisseur_price]', $Tab, $TAssetOFLine->fk_product_fournisseur_price != 0 ? $TAssetOFLine->fk_product_fournisseur_price : $selected, 1, '', 'style="max-width:250px;"'), 'delete' => $form->type_aff == 'edit' && $of->status == 'DRAFT' ? '<a href="#null" onclick="deleteLine(' . $TAssetOFLine->getId() . ',\'TO_MAKE\');">' . img_picto('Supprimer', 'delete.png') . '</a>' : '', 'fk_entrepot' => !empty($conf->global->ASSET_MANUAL_WAREHOUSE) && ($of->status == 'DRAFT' || $of->status == 'VALID' || $of->status == 'NEEDOFFER' || $of->status == 'ONORDER' || $of->status == 'OPEN') && $form->type_aff == 'edit' ? $formProduct->selectWarehouses($TAssetOFLine->fk_entrepot, 'TAssetOFLine[' . $k . '][fk_entrepot]', '', 0, 0, $TAssetOFLine->fk_product) : $TAssetOFLine->getLibelleEntrepot($PDOdb));
            $action = $form->type_aff;
            $parameter = array('of' => &$of, 'line' => &$TLine, 'type' => 'TO_MAKE');
            $res = $hookmanager->executeHooks('lineObjectOptions', $parameter, $TAssetOFLine, $action);
            if ($res > 0 && !empty($hookmanager->resArray)) {
                $TLine = $hookmanager->resArray;
            }
            $TRes[] = $TLine;
        }
    }
    return $TRes;
}