Example #1
0
     if ($resqlm) {
         $objtp = $db->fetch_object($resqlm);
         if (!empty($objtp->label)) {
             $objp->label = $objtp->label;
         }
     }
 }
 $var = !$var;
 if ($usevirtualstock) {
     // If option to increase/decrease is not on an object validation, virtual stock may differs from physical stock.
     $stock = $prod->stock_theorique;
 } else {
     $stock = $prod->stock_reel;
 }
 // Force call prod->load_stats_xxx to choose status to count (otherwise it is loaded by load_stock function)
 $result = $prod->load_stats_commande_fournisseur(0, '1,2,3,4');
 $result = $prod->load_stats_reception(0, '4');
 //print $prod->stats_commande_fournisseur['qty'].'<br>'."\n";
 //print $prod->stats_reception['qty'];
 $ordered = $prod->stats_commande_fournisseur['qty'] - $prod->stats_reception['qty'];
 $warning = '';
 if ($objp->alertstock && $stock < $objp->alertstock) {
     $warning = img_warning($langs->trans('StockTooLow')) . ' ';
 }
 //depending on conf, use either physical stock or
 //virtual stock to compute the stock to buy value
 $stocktobuy = max(max($objp->desiredstock, $objp->alertstock) - $stock - $ordered, 0);
 $disabled = '';
 if ($ordered > 0) {
     $stockforcompare = $usevirtualstock ? $stock : $stock + $ordered;
     if ($stockforcompare >= $objp->desiredstock) {
Example #2
0
 // stock order and stock order_supplier
 $stock_order = 0;
 $stock_order_supplier = 0;
 if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
     if (!empty($conf->commande->enabled)) {
         if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) {
             $generic_product->load_stats_commande(0, '1,2');
             $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty'];
         } else {
             $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'];
         }
         $stock_order = $generic_product->stats_commande['qty'];
     }
     if (!empty($conf->fournisseur->enabled)) {
         if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) {
             $generic_product->load_stats_commande_fournisseur(0, '3');
             $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
         } else {
             $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'];
         }
         $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty'];
     }
 }
 $text_info .= $generic_commande->lines[$lig]->qty . ' X ' . $generic_commande->lines[$lig]->ref . '&nbsp;' . dol_trunc($generic_commande->lines[$lig]->product_label, 25);
 $text_stock_reel = $generic_product->stock_reel . '/' . $stock_order;
 if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) {
     $warning++;
     $text_warning .= '<span class="warning">' . $langs->trans('Available') . '&nbsp;:&nbsp;' . $text_stock_reel . '</span>';
 }
 if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) {
     $notshippable++;
Example #3
0
/**
 * Show stats for company
 *
 * @param	Product		$product	Product object
 * @param 	int			$socid		Thirdparty id
 * @return	integer
 */
function show_stats_for_company($product, $socid)
{
    global $conf, $langs, $user, $db;
    print '<tr>';
    print '<td align="left" width="25%" valign="top">' . $langs->trans("Referers") . '</td>';
    print '<td align="right" width="25%">' . $langs->trans("NbOfThirdParties") . '</td>';
    print '<td align="right" width="25%">' . $langs->trans("NbOfReferers") . '</td>';
    print '<td align="right" width="25%">' . $langs->trans("TotalQuantity") . '</td>';
    print '</tr>';
    // Propals
    if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
        $ret = $product->load_stats_propale($socid);
        if ($ret < 0) {
            dol_print_error($db);
        }
        $langs->load("propal");
        print '<tr><td>';
        print '<a href="propal.php?id=' . $product->id . '">' . img_object('', 'propal') . ' ' . $langs->trans("Proposals") . '</a>';
        print '</td><td align="right">';
        print $product->stats_propale['customers'];
        print '</td><td align="right">';
        print $product->stats_propale['nb'];
        print '</td><td align="right">';
        print $product->stats_propale['qty'];
        print '</td>';
        print '</tr>';
    }
    // Commandes clients
    if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
        $ret = $product->load_stats_commande($socid);
        if ($ret < 0) {
            dol_print_error($db);
        }
        $langs->load("orders");
        print '<tr><td>';
        print '<a href="commande.php?id=' . $product->id . '">' . img_object('', 'order') . ' ' . $langs->trans("CustomersOrders") . '</a>';
        print '</td><td align="right">';
        print $product->stats_commande['customers'];
        print '</td><td align="right">';
        print $product->stats_commande['nb'];
        print '</td><td align="right">';
        print $product->stats_commande['qty'];
        print '</td>';
        print '</tr>';
    }
    // Commandes fournisseurs
    if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) {
        $ret = $product->load_stats_commande_fournisseur($socid);
        if ($ret < 0) {
            dol_print_error($db);
        }
        $langs->load("orders");
        print '<tr><td>';
        print '<a href="commande_fournisseur.php?id=' . $product->id . '">' . img_object('', 'order') . ' ' . $langs->trans("SuppliersOrders") . '</a>';
        print '</td><td align="right">';
        print $product->stats_commande_fournisseur['suppliers'];
        print '</td><td align="right">';
        print $product->stats_commande_fournisseur['nb'];
        print '</td><td align="right">';
        print $product->stats_commande_fournisseur['qty'];
        print '</td>';
        print '</tr>';
    }
    // Contrats
    if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
        $ret = $product->load_stats_contrat($socid);
        if ($ret < 0) {
            dol_print_error($db);
        }
        $langs->load("contracts");
        print '<tr><td>';
        print '<a href="contrat.php?id=' . $product->id . '">' . img_object('', 'contract') . ' ' . $langs->trans("Contracts") . '</a>';
        print '</td><td align="right">';
        print $product->stats_contrat['customers'];
        print '</td><td align="right">';
        print $product->stats_contrat['nb'];
        print '</td><td align="right">';
        print $product->stats_contrat['qty'];
        print '</td>';
        print '</tr>';
    }
    // Factures clients
    if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
        $ret = $product->load_stats_facture($socid);
        if ($ret < 0) {
            dol_print_error($db);
        }
        $langs->load("bills");
        print '<tr><td>';
        print '<a href="facture.php?id=' . $product->id . '">' . img_object('', 'bill') . ' ' . $langs->trans("CustomersInvoices") . '</a>';
        print '</td><td align="right">';
        print $product->stats_facture['customers'];
        print '</td><td align="right">';
        print $product->stats_facture['nb'];
        print '</td><td align="right">';
        print $product->stats_facture['qty'];
        print '</td>';
        print '</tr>';
    }
    // Factures fournisseurs
    if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) {
        $ret = $product->load_stats_facture_fournisseur($socid);
        if ($ret < 0) {
            dol_print_error($db);
        }
        $langs->load("bills");
        print '<tr><td>';
        print '<a href="facture_fournisseur.php?id=' . $product->id . '">' . img_object('', 'bill') . ' ' . $langs->trans("SuppliersInvoices") . '</a>';
        print '</td><td align="right">';
        print $product->stats_facture_fournisseur['suppliers'];
        print '</td><td align="right">';
        print $product->stats_facture_fournisseur['nb'];
        print '</td><td align="right">';
        print $product->stats_facture_fournisseur['qty'];
        print '</td>';
        print '</tr>';
    }
    return 0;
}