Example #1
0
 //}
 if ($contractline->date_fin_validite) {
     $text .= '<br>' . $langs->trans("ExpiredSince") . ': ' . dol_print_date($contractline->date_fin_validite);
 }
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $langs->trans("Designation");
 print '</td><td class="CTableRow' . ($var ? '1' : '2') . '">' . $text;
 print '<input type="hidden" name="source" value="' . GETPOST("source", 'alpha') . '">';
 print '<input type="hidden" name="ref" value="' . $contractline->ref . '">';
 print '</td></tr>' . "\n";
 // Quantity
 $var = !$var;
 $label = $langs->trans("Quantity");
 $qty = 1;
 $duration = '';
 if ($contractline->fk_product) {
     if ($product->isService() && $product->duration_value > 0) {
         $label = $langs->trans("Duration");
         // TODO Put this in a global method
         if ($product->duration_value > 1) {
             $dur = array("h" => $langs->trans("Hours"), "d" => $langs->trans("DurationDays"), "w" => $langs->trans("DurationWeeks"), "m" => $langs->trans("DurationMonths"), "y" => $langs->trans("DurationYears"));
         } else {
             $dur = array("h" => $langs->trans("Hour"), "d" => $langs->trans("DurationDay"), "w" => $langs->trans("DurationWeek"), "m" => $langs->trans("DurationMonth"), "y" => $langs->trans("DurationYear"));
         }
         $duration = $product->duration_value . ' ' . $dur[$product->duration_unit];
     }
 }
 print '<tr class="CTableRow' . ($var ? '1' : '2') . '"><td class="CTableRow' . ($var ? '1' : '2') . '">' . $label . '</td>';
 print '<td class="CTableRow' . ($var ? '1' : '2') . '"><b>' . ($duration ? $duration : $qty) . '</b>';
 print '<input type="hidden" name="newqty" value="' . dol_escape_htmltag($qty) . '">';
 print '</b></td></tr>' . "\n";
 // Amount
Example #2
0
/**
 * Prepare array with list of tabs
 *
 * @param   Product	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function product_prepare_head($object)
{
    global $langs, $conf, $user;
    $langs->load("products");
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . "/product/card.php?id=" . $object->id;
    $head[$h][1] = $langs->trans("Card");
    $head[$h][2] = 'card';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . "/product/price.php?id=" . $object->id;
    $head[$h][1] = $langs->trans("SellingPrices");
    $head[$h][2] = 'price';
    $h++;
    if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire || !empty($conf->margin->enabled) && $user->rights->margin->liretous) {
        $head[$h][0] = DOL_URL_ROOT . "/product/fournisseurs.php?id=" . $object->id;
        $head[$h][1] = $langs->trans("BuyingPrices");
        $head[$h][2] = 'suppliers';
        $h++;
    }
    // Show category tab
    /* No more required. Replaced with new multiselect component
    	if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire)
    	{
    		require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
    		$type = Categorie::TYPE_PRODUCT;
    		$head[$h][0] = DOL_URL_ROOT."/categories/categorie.php?id=".$object->id.'&type='.$type;
    		$head[$h][1] = $langs->trans('Categories');
    		$head[$h][2] = 'category';
    		$h++;
    	}*/
    // Multilangs
    if (!empty($conf->global->MAIN_MULTILANGS)) {
        $head[$h][0] = DOL_URL_ROOT . "/product/traduction.php?id=" . $object->id;
        $head[$h][1] = $langs->trans("Translation");
        $head[$h][2] = 'translation';
        $h++;
    }
    // Sub products
    if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
        $head[$h][0] = DOL_URL_ROOT . "/product/composition/card.php?id=" . $object->id;
        $head[$h][1] = $langs->trans('AssociatedProducts');
        $head[$h][2] = 'subproduct';
        $h++;
    }
    $head[$h][0] = DOL_URL_ROOT . "/product/stats/card.php?id=" . $object->id;
    $head[$h][1] = $langs->trans('Statistics');
    $head[$h][2] = 'stats';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . "/product/stats/facture.php?id=" . $object->id;
    $head[$h][1] = $langs->trans('Referers');
    $head[$h][2] = 'referers';
    $h++;
    if ($object->isProduct() || $object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
        if (!empty($conf->stock->enabled) && $user->rights->stock->lire) {
            $head[$h][0] = DOL_URL_ROOT . "/product/stock/product.php?id=" . $object->id;
            $head[$h][1] = $langs->trans("Stock");
            $head[$h][2] = 'stock';
            $h++;
        }
    }
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'product');
    /* Merged into the Join files tab
    	$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$object->id;
    	$head[$h][1] = $langs->trans("Photos");
    	$head[$h][2] = 'photos';
    	$h++;
    	*/
    // Attachments
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    if (!empty($conf->product->enabled)) {
        $upload_dir = $conf->product->multidir_output[$object->entity] . '/' . dol_sanitizeFileName($object->ref);
    } elseif (!empty($conf->service->enabled)) {
        $upload_dir = $conf->service->multidir_output[$object->entity] . '/' . dol_sanitizeFileName($object->ref);
    }
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/product/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Documents');
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'product', 'remove');
    // Log
    $head[$h][0] = DOL_URL_ROOT . '/product/info.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Info");
    $head[$h][2] = 'info';
    $h++;
    return $head;
}
Example #3
0
/**
 *  Return line description translated in outputlangs and encoded into htmlentities and with <br>
 *
 *  @param  Object		$object              Object
 *  @param  int			$i                   Current line number (0 = first line, 1 = second line, ...)
 *  @param  Translate	$outputlangs         Object langs for output
 *  @param  int			$hideref             Hide reference
 *  @param  int			$hidedesc            Hide description
 *  @param  int			$issupplierline      Is it a line for a supplier object ?
 *  @return string       				     String with line
 */
function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
{
    global $db, $conf, $langs;
    $idprod = !empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false;
    $label = !empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '');
    $desc = !empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '');
    $ref_supplier = !empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '');
    // TODO Not yet saved for supplier invoices, only supplier orders
    $note = !empty($object->lines[$i]->note) ? $object->lines[$i]->note : '';
    $dbatch = !empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false;
    if ($issupplierline) {
        $prodser = new ProductFournisseur($db);
    } else {
        $prodser = new Product($db);
    }
    if ($idprod) {
        $prodser->fetch($idprod);
        // If a predefined product and multilang and on other lang, we renamed label with label translated
        if (!empty($conf->global->MAIN_MULTILANGS) && $outputlangs->defaultlang != $langs->defaultlang) {
            $translatealsoifmodified = !empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED);
            // By default if value was modified manually, we keep it (no translation because we don't have it)
            // TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
            // ($textwasmodified is replaced with $textwasmodifiedorcompleted and we add completion).
            // Set label
            // If we want another language, and if label is same than default language (we did force it to a specific value), we can use translation.
            //var_dump($outputlangs->defaultlang.' - '.$langs->defaultlang.' - '.$label.' - '.$prodser->label);exit;
            $textwasmodified = $label == $prodser->label;
            if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && ($textwasmodified || $translatealsoifmodified)) {
                $label = $prodser->multilangs[$outputlangs->defaultlang]["label"];
            }
            // Set desc
            // Manage HTML entities description test because $prodser->description is store with htmlentities but $desc no
            $textwasmodified = false;
            if (!empty($desc) && dol_textishtml($desc) && !empty($prodser->description) && dol_textishtml($prodser->description)) {
                $textwasmodified = strpos(dol_html_entity_decode($desc, ENT_QUOTES | ENT_HTML401), dol_html_entity_decode($prodser->description, ENT_QUOTES | ENT_HTML401)) !== false;
            } else {
                $textwasmodified = $desc == $prodser->description;
            }
            if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && ($textwasmodified || $translatealsoifmodified)) {
                $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
            }
            // Set note
            $textwasmodified = $note == $prodser->note;
            if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) {
                $note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
            }
        }
    }
    // Description short of product line
    $libelleproduitservice = $label;
    // Description long of product line
    if (!empty($desc) && $desc != $label) {
        if ($libelleproduitservice && empty($hidedesc)) {
            $libelleproduitservice .= '__N__';
        }
        if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) {
            $discount = new DiscountAbsolute($db);
            $discount->fetch($object->lines[$i]->fk_remise_except);
            $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source);
        } elseif ($desc == '(DEPOSIT)' && $object->lines[$i]->fk_remise_except) {
            $discount = new DiscountAbsolute($db);
            $discount->fetch($object->lines[$i]->fk_remise_except);
            $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source);
            // Add date of deposit
            if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
                echo ' (' . dol_print_date($discount->datec, 'day', '', $outputlangs) . ')';
            }
        } else {
            if ($idprod) {
                if (empty($hidedesc)) {
                    $libelleproduitservice .= $desc;
                }
            } else {
                $libelleproduitservice .= $desc;
            }
        }
    }
    // If line linked to a product
    if ($idprod) {
        // We add ref
        if ($prodser->ref) {
            $prefix_prodserv = "";
            $ref_prodserv = "";
            if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
                if ($prodser->isService()) {
                    $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service") . " ";
                } else {
                    $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product") . " ";
                }
            }
            if (empty($hideref)) {
                if ($issupplierline) {
                    $ref_prodserv = $prodser->ref . ($ref_supplier ? ' (' . $outputlangs->transnoentitiesnoconv("SupplierRef") . ' ' . $ref_supplier . ')' : '');
                } else {
                    $ref_prodserv = $prodser->ref;
                }
                // Show local ref only
                if (!empty($libelleproduitservice)) {
                    $ref_prodserv .= " - ";
                }
            }
            $libelleproduitservice = $prefix_prodserv . $ref_prodserv . $libelleproduitservice;
        }
    }
    // Add an additional description for the category products
    if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) {
        include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
        $categstatic = new Categorie($db);
        // recovering the list of all the categories linked to product
        $tblcateg = $categstatic->containing($idprod, Categorie::TYPE_PRODUCT);
        foreach ($tblcateg as $cate) {
            // Adding the descriptions if they are filled
            $desccateg = $cate->add_description;
            if ($desccateg) {
                $libelleproduitservice .= '__N__' . $desccateg;
            }
        }
    }
    if (!empty($object->lines[$i]->date_start) || !empty($object->lines[$i]->date_end)) {
        $format = 'day';
        // Show duration if exists
        if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) {
            $period = '(' . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs), dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)) . ')';
        }
        if ($object->lines[$i]->date_start && !$object->lines[$i]->date_end) {
            $period = '(' . $outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)) . ')';
        }
        if (!$object->lines[$i]->date_start && $object->lines[$i]->date_end) {
            $period = '(' . $outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)) . ')';
        }
        //print '>'.$outputlangs->charset_output.','.$period;
        $libelleproduitservice .= "__N__" . $period;
        //print $libelleproduitservice;
    }
    if ($dbatch) {
        $format = 'day';
        foreach ($dbatch as $detail) {
            $dte = array();
            if ($detail->eatby) {
                $dte[] = $outputlangs->transnoentitiesnoconv('printEatby', dol_print_date($detail->eatby, $format, false, $outputlangs));
            }
            if ($detail->sellby) {
                $dte[] = $outputlangs->transnoentitiesnoconv('printSellby', dol_print_date($detail->sellby, $format, false, $outputlangs));
            }
            if ($detail->batch) {
                $dte[] = $outputlangs->transnoentitiesnoconv('printBatch', $detail->batch);
            }
            $dte[] = $outputlangs->transnoentitiesnoconv('printQty', $detail->dluo_qty);
            $libelleproduitservice .= "__N__  " . implode($dte, "-");
        }
    }
    // Now we convert \n into br
    if (dol_textishtml($libelleproduitservice)) {
        $libelleproduitservice = preg_replace('/__N__/', '<br>', $libelleproduitservice);
    } else {
        $libelleproduitservice = preg_replace('/__N__/', "\n", $libelleproduitservice);
    }
    $libelleproduitservice = dol_htmlentitiesbr($libelleproduitservice, 1);
    return $libelleproduitservice;
}
Example #4
0
/**
 *  Return line description translated in outputlangs and encoded into UTF8
 *
 *  @param  Line		$line                Current line number (0 = first line, 1 = second line, ...)
 *  @param  Translate	$outputlangs         Object langs for output
 *  @param  int			$hideref             Hide reference
 *  @param  int			$hidedesc            Hide description
 *  @param  int			$issupplierline      Is it a line for a supplier object ?
 *  @return string       				     String with line
 */
function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
{
    global $db, $conf, $langs;
    $idprod = $line->fk_product;
    $label = !empty($line->label) ? $line->label : (!empty($line->libelle) ? $line->libelle : '');
    $desc = !empty($line->desc) ? $line->desc : (!empty($line->description) ? $line->description : '');
    $ref_supplier = !empty($line->ref_supplier) ? $line->ref_supplier : (!empty($line->ref_fourn) ? $line->ref_fourn : '');
    // TODO Not yet saved for supplier invoices, only supplier orders
    $note = !empty($line->note) ? $line->note : '';
    if ($issupplierline) {
        $prodser = new ProductFournisseur($db);
    } else {
        $prodser = new Product($db);
    }
    if ($idprod) {
        $prodser->fetch($idprod);
        // If a predefined product and multilang and on other lang, we renamed label with label translated
        if (!empty($conf->global->MAIN_MULTILANGS) && $outputlangs->defaultlang != $langs->defaultlang) {
            if (!empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) {
                $label = $prodser->multilangs[$outputlangs->defaultlang]["label"];
            }
            if (!empty($prodser->multilangs[$outputlangs->defaultlang]["description"]) && $desc == $prodser->description) {
                $desc = $prodser->multilangs[$outputlangs->defaultlang]["description"];
            }
            if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && $note == $prodser->note) {
                $note = $prodser->multilangs[$outputlangs->defaultlang]["note"];
            }
        }
    }
    // Description short of product line
    $libelleproduitservice = $label;
    // Description long of product line
    if ($desc && $desc != $label) {
        if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) {
            $discount = new DiscountAbsolute($db);
            $discount->fetch($line->fk_remise_except);
            $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $discount->ref_facture_source);
        } elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except) {
            $discount = new DiscountAbsolute($db);
            $discount->fetch($line->fk_remise_except);
            $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $discount->ref_facture_source);
            // Add date of deposit
            if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
                $libelleproduitservice .= ' (' . dol_print_date($discount->datec, 'day', '', $outputlangs) . ')';
            }
        } else {
            if ($idprod) {
                if (empty($hidedesc)) {
                    $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc);
                }
            } else {
                $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc);
            }
        }
    }
    // If line linked to a product
    if ($idprod) {
        // On ajoute la ref
        if ($prodser->ref) {
            $prefix_prodserv = "";
            $ref_prodserv = "";
            if (!empty($conf->global->PRODUCT_ADD_TYPE_IN_DOCUMENTS)) {
                if ($prodser->isService()) {
                    $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Service") . " ";
                } else {
                    $prefix_prodserv = $outputlangs->transnoentitiesnoconv("Product") . " ";
                }
            }
            if (empty($hideref)) {
                if ($issupplierline) {
                    $ref_prodserv = $prodser->ref . ' (' . $outputlangs->trans("SupplierRef") . ' ' . $ref_supplier . ')';
                } else {
                    $ref_prodserv = $prodser->ref;
                }
                // Show local ref only
                $ref_prodserv .= " - ";
            }
            $libelleproduitservice = $prefix_prodserv . $ref_prodserv . $libelleproduitservice;
        }
    }
    if (!empty($line->date_start) || !empty($line->date_end)) {
        $format = 'day';
        // Show duration if exists
        if ($line->date_start && $line->date_end) {
            $period = '(' . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)) . ')';
        }
        if ($line->date_start && !$line->date_end) {
            $period = '(' . $outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)) . ')';
        }
        if (!$line->date_start && $line->date_end) {
            $period = '(' . $outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)) . ')';
        }
        //print '>'.$outputlangs->charset_output.','.$period;
        $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period);
        //print $libelleproduitservice;
    }
    return $libelleproduitservice;
}