function _product_link($fk_product)
{
    global $db, $langs, $conf;
    $p = new Product($db);
    $p->fetch($fk_product);
    return $p->getNomUrl(1) . ' ' . $p->label;
}
 function mouvement(&$PDOdb, &$object, $fk_product, $qty, $fk_warehouse_from, $fk_warehouse_to)
 {
     global $db, $user, $langs;
     dol_include_once('/product/stock/class/mouvementstock.class.php');
     dol_include_once('/product/class/product.class.php');
     /*var_dump($fk_product, $qty,$fk_warehouse_from, $fk_warehouse_to);
     		exit;
     			*/
     $stock = new MouvementStock($db);
     $label = '';
     if (method_exists($object, 'getNomUrl')) {
         $label .= $object->getNomUrl(1);
     }
     if (!empty($conf->global->ROUTING_INFO_ALERT)) {
         $product = new Product($db);
         $product->fetch($fk_product);
         $msg = $product->getNomUrl(0) . ' ' . $product->label . ' ' . $langs->trans('MoveFrom') . ' ' . $wh_from_label . ' ' . $langs->trans('MoveTo') . ' ' . $wh_to_label;
         setEventMessage($msg);
     }
     $stock->origin = $object;
     $stock->reception($user, $fk_product, $fk_warehouse_to, $qty, 0, $label);
     $stock->livraison($user, $fk_product, $fk_warehouse_from, $qty, 0, $label);
 }
            while ($obj = $db->fetch_object($res)) {
                $o = new Propal($db);
                $o->fetch($obj->rowid);
                $Tab[] = array('link' => $o->getNomUrl(1), 'link0' => $o->getNomUrl(0), 'type' => 'user');
            }
            $res = $db->query("SELECT rowid  FROM " . MAIN_DB_PREFIX . "facture WHERE facnumber = '" . $db->escape($tag) . "'");
            while ($obj = $db->fetch_object($res)) {
                $o = new Facture($db);
                $o->fetch($obj->rowid);
                $Tab[] = array('link' => $o->getNomUrl(1), 'link0' => $o->getNomUrl(0), 'type' => 'societe');
            }
            $res = $db->query("SELECT rowid  FROM " . MAIN_DB_PREFIX . "product WHERE ref = '" . $db->escape($tag) . "'");
            while ($obj = $db->fetch_object($res)) {
                $o = new Product($db);
                $o->fetch($obj->rowid);
                $Tab[] = array('link' => $o->getNomUrl(1), 'link0' => $o->getNomUrl(0), 'type' => 'societe');
            }
        } else {
        }
    }
}
if (count($Tab) == 1) {
    preg_match_all('/<a[^>]+href=([\'"])(.+?)\\1[^>]*>/i', $Tab[0]['link0'], $match);
    if (!empty($match[2][0])) {
        header('location:' . $match[2][0]);
        exit;
    }
}
llxHeader();
dol_fiche_head();
if (empty($Tab)) {
Example #4
0
     $type = 1;
 }
 if (!empty($fields['ddate_end'])) {
     $type = 1;
 }
 $var = !$var;
 print '<tr ' . $bc[$var] . '>';
 // Ref
 print '<td class="nowrap" align="left">' . $fields['link'] . '</td>';
 // Description
 print '<td align="left">';
 if ($fields['pid']) {
     $product_static->id = $fields['pid'];
     $product_static->ref = $fields['pref'];
     $product_static->type = $fields['ptype'];
     print $product_static->getNomUrl(1);
     if (dol_string_nohtmltag($fields['descr'])) {
         print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 16);
     }
 } else {
     if ($type) {
         $text = img_object($langs->trans('Service'), 'service');
     } else {
         $text = img_object($langs->trans('Product'), 'product');
     }
     if (preg_match('/^\\((.*)\\)$/', $fields['descr'], $reg)) {
         if ($reg[1] == 'DEPOSIT') {
             $fields['descr'] = $langs->transnoentitiesnoconv('Deposit');
         } elseif ($reg[1] == 'CREDIT_NOTE') {
             $fields['descr'] = $langs->transnoentitiesnoconv('CreditNote');
         } else {
Example #5
0
     }
 }
 $product_static->id = $objp->rowid;
 $product_static->ref = $objp->ref;
 $product_static->ref_fourn = $objp->ref_supplier;
 $product_static->label = $objp->label;
 $product_static->type = $objp->fk_product_type;
 $product_static->status_buy = $objp->tobuy;
 $product_static->status = $objp->tosell;
 $product_static->entity = $objp->entity;
 $var = !$var;
 print '<tr ' . $bc[$var] . '>';
 // Ref
 if (!empty($arrayfields['p.ref']['checked'])) {
     print '<td class="nowrap">';
     print $product_static->getNomUrl(1, '', 24);
     print "</td>\n";
 }
 // Ref supplier
 if (!empty($arrayfields['pfp.ref_fourn']['checked'])) {
     print '<td class="nowrap">';
     print $product_static->getNomUrl(1, '', 24);
     print "</td>\n";
 }
 // Label
 if (!empty($arrayfields['p.label']['checked'])) {
     print '<td>' . dol_trunc($objp->label, 40) . '</td>';
 }
 // Barcode
 if (!empty($arrayfields['p.barcode']['checked'])) {
     print '<td>' . $objp->barcode . '</td>';
Example #6
0
 $obj = $db->fetch_object($resql);
 $var = !$var;
 print "<tr " . $bc[$var] . ">";
 print '<td>';
 $contractstatic->id = $obj->cid;
 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
 print $contractstatic->getNomUrl(1, 16);
 print '</td>';
 // Service
 print '<td>';
 if ($obj->pid) {
     $productstatic->id = $obj->pid;
     $productstatic->type = $obj->ptype;
     $productstatic->ref = $obj->pref;
     $productstatic->entity = $obj->pentity;
     print $productstatic->getNomUrl(1, '', 20);
     print $obj->label ? ' - ' . dol_trunc($obj->label, 16) : '';
     if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) {
         print '<br>' . dol_nl2br($obj->description);
     }
 } else {
     if ($obj->type == 0) {
         print img_object($obj->description, 'product') . dol_trunc($obj->description, 20);
     }
     if ($obj->type == 1) {
         print img_object($obj->description, 'service') . dol_trunc($obj->description, 20);
     }
 }
 print '</td>';
 // Third party
 print '<td>';
Example #7
0
$thirdpartytmp = new Societe($db);
/*
 * Actions
 */
if (GETPOST('submitproduct') && GETPOST('submitproduct')) {
    $action = '';
    // We reset because we don't want to build doc
    if (GETPOST('productid') > 0) {
        $producttmp->fetch(GETPOST('productid'));
        $forbarcode = $producttmp->barcode;
        $fk_barcode_type = $thirdpartytmp->barcode_type_code;
        if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
            $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
        }
        if (empty($forbarcode) || empty($fk_barcode_type)) {
            setEventMessages($langs->trans("DefinitionOfBarCodeForProductNotComplete", $producttmp->getNomUrl()), null, 'warnings');
        }
    }
}
if (GETPOST('submitthirdparty') && GETPOST('submitthirdparty')) {
    $action = '';
    // We reset because we don't want to build doc
    if (GETPOST('socid') > 0) {
        $thirdpartytmp->fetch(GETPOST('socid'));
        $forbarcode = $thirdpartytmp->barcode;
        $fk_barcode_type = $thirdpartytmp->barcode_type_code;
        if (empty($fk_barcode_type) && !empty($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY)) {
            $fk_barcode_type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY;
        }
        if (empty($forbarcode) || empty($fk_barcode_type)) {
            setEventMessages($langs->trans("DefinitionOfBarCodeForThirdpartyNotComplete", $thirdpartytmp->getNomUrl()), null, 'warnings');
function get_format_libelle_produit($fk_product = null)
{
    global $db, $langs;
    if (!empty($fk_product)) {
        $TId = explode(',', $fk_product);
        $nb_product = count($TId);
        $product = new Product($db);
        $product->fetch($TId[0]);
        $product->ref .= ' ' . $product->label;
        $res = $product->getNomUrl(1) . ($nb_product > 1 ? ' + ' . ($nb_product - 1) . ' ' . $langs->trans('products') : '');
        return $res;
    } else {
        return 'Produit non défini.';
    }
}
 /**
  *  Load data into info_box_contents array to show array later.
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 5)
 {
     global $user, $langs, $db, $conf;
     $this->max = $max;
     include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
     $productstatic = new Product($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max));
     if ($user->rights->produit->lire || $user->rights->service->lire) {
         $sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte,";
         $sql .= " SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ") as total_stock";
         $sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock as s on p.rowid = s.fk_product";
         $sql .= ' WHERE p.entity IN (' . getEntity($productstatic->element, 1) . ')';
         $sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
         if (empty($user->rights->produit->lire)) {
             $sql .= ' AND p.fk_product_type != 0';
         }
         if (empty($user->rights->service->lire)) {
             $sql .= ' AND p.fk_product_type != 1';
         }
         $sql .= " GROUP BY p.rowid, p.ref, p.label, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.seuil_stock_alerte";
         $sql .= " HAVING SUM(" . $db->ifsql("s.reel IS NULL", "0", "s.reel") . ") < p.seuil_stock_alerte";
         $sql .= $db->order('p.seuil_stock_alerte', 'DESC');
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $langs->load("stocks");
             $num = $db->num_rows($result);
             $line = 0;
             while ($line < $num) {
                 $objp = $db->fetch_object($result);
                 $datem = $db->jdate($objp->tms);
                 // Multilangs
                 if (!empty($conf->global->MAIN_MULTILANGS)) {
                     $sqld = "SELECT label";
                     $sqld .= " FROM " . MAIN_DB_PREFIX . "product_lang";
                     $sqld .= " WHERE fk_product=" . $objp->rowid;
                     $sqld .= " AND lang='" . $langs->getDefaultLang() . "'";
                     $sqld .= " LIMIT 1";
                     $resultd = $db->query($sqld);
                     if ($resultd) {
                         $objtp = $db->fetch_object($resultd);
                         if (isset($objtp->label) && $objtp->label != '') {
                             $objp->label = $objtp->label;
                         }
                     }
                 }
                 $productstatic->id = $objp->rowid;
                 $productstatic->ref = $objp->ref;
                 $productstatic->type = $objp->fk_product_type;
                 $productstatic->label = $objp->label;
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $productstatic->getNomUrl(1), 'asis' => 1);
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $objp->label);
                 if (empty($objp->fk_price_expression)) {
                     $price_base_type = $langs->trans($objp->price_base_type);
                     $price = $objp->price_base_type == 'HT' ? price($objp->price) : ($price = price($objp->price_ttc));
                 } else {
                     $productstatic->fetch($objp->rowid, '', '', 1);
                     $priceparser = new PriceParser($this->db);
                     $price_result = $priceparser->parseProduct($productstatic);
                     if ($price_result >= 0) {
                         if ($objp->price_base_type == 'HT') {
                             $price_base_type = $langs->trans("HT");
                         } else {
                             $price_result = $price_result * (1 + $productstatic->tva_tx / 100);
                             $price_base_type = $langs->trans("TTC");
                         }
                         $price = price($price_result);
                     }
                 }
                 $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => $price);
                 $this->info_box_contents[$line][] = array('td' => 'align="left" class="nowrap"', 'text' => $price_base_type);
                 $this->info_box_contents[$line][] = array('td' => 'align="center"', 'text' => $objp->total_stock . ' / ' . $objp->seuil_stock_alerte, 'text2' => img_warning($langs->transnoentitiesnoconv("StockLowerThanLimit")));
                 $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $productstatic->LibStatut($objp->tosell, 3, 0));
                 $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $productstatic->LibStatut($objp->tobuy, 3, 1));
                 $line++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoTooLowStockProducts"));
             }
             $db->free($result);
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     } else {
         $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
Example #10
0
     $stockforcompare = $usevirtualstock ? $stock : $stock + $ordered;
     if ($stockforcompare >= $objp->desiredstock) {
         $picto = img_picto('', './img/yes', '', 1);
         $disabled = 'disabled';
     } else {
         $picto = img_picto('', './img/no', '', 1);
     }
 } else {
     //$picto = img_help('',$langs->trans("NoPendingReceptionOnSupplierOrder"));
     $picto = img_picto($langs->trans("NoPendingReceptionOnSupplierOrder"), './img/no', '', 1);
 }
 print '<tr ' . $bc[$var] . '>';
 // Select field
 //print '<td><input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td>';
 print '<td><input type="checkbox" class="check" name="' . $i . '"></td>';
 print '<td class="nowrap">' . $prod->getNomUrl(1, '', 16) . '</td>';
 print '<td>' . $objp->label . '<input type="hidden" name="desc' . $i . '" value="' . $objp->label . '" ></td>';
 if (!empty($conf->service->enabled) && $type == 1) {
     if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) {
         $duration = $regs[1] . ' ' . $langs->trans('DurationYear');
     } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) {
         $duration = $regs[1] . ' ' . $langs->trans('DurationMonth');
     } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) {
         $duration = $regs[1] . ' ' . $langs->trans('DurationDay');
     } else {
         $duration = $objp->duration;
     }
     print '<td align="center">' . $duration . '</td>';
 }
 // Desired stock
 print '<td align="right">' . $objp->desiredstock . '</td>';
function tabImport(&$TImport, &$expedition)
{
    global $langs, $db;
    $form = new TFormCore();
    $formDoli = new Form($db);
    $formproduct = new FormProduct($db);
    $PDOdb = new TPDOdb();
    print count($TImport) . ' équipement(s) dans votre expédition';
    ?>
	<table width="100%" class="border">
		<tr class="liste_titre">
			<td>Produit</td>
			<td>Numéro de série</td>
			<td>Numéro de Lot</td>
			<td>Quantité</td>
			<td>&nbsp;</td>
		</tr>
		
	<?php 
    $prod = new Product($db);
    $form->Set_typeaff('view');
    if (is_array($TImport)) {
        foreach ($TImport as $k => $line) {
            if ($prod->id == 0 || $line['ref'] != $prod->ref) {
                if (!empty($line['fk_product'])) {
                    $prod->fetch($line['fk_product']);
                } else {
                    $prod->fetch('', $line['ref']);
                }
            }
            $asset = new TAsset();
            $asset->loadBy($PDOdb, $line['numserie'], 'serial_number');
            $asset->load_asset_type($PDOdb);
            $assetLot = new TAssetLot();
            $assetLot->loadBy($PDOdb, $line['lot_number'], 'lot_number');
            $Trowid = TRequeteCore::get_id_from_what_you_want($PDOdb, MAIN_DB_PREFIX . "expeditiondet_asset", array('fk_asset' => $asset->rowid, 'fk_expeditiondet' => $line['fk_expeditiondet']));
            ?>
<tr>
					<td><?php 
            echo $prod->getNomUrl(1) . $form->hidden('TLine[' . $k . '][fk_product]', $prod->id) . $form->hidden('TLine[' . $k . '][ref]', $prod->ref);
            ?>
</td>
					<td><a href="<?php 
            echo dol_buildpath('/asset/fiche.php?id=' . $asset->rowid, 1);
            ?>
"><?php 
            echo $form->texte('', 'TLine[' . $k . '][numserie]', $line['numserie'], 30);
            ?>
</a></td>
					<td><a href="<?php 
            echo dol_buildpath('/asset/fiche_lot.php?id=' . $assetLot->rowid, 1);
            ?>
"><?php 
            echo $form->texte('', 'TLine[' . $k . '][lot_number]', $line['lot_number'], 30);
            ?>
</a></td>
					<td><?php 
            echo $line['quantity'] . " " . ($asset->assetType->measuring_units == 'unit' ? 'unité(s)' : measuring_units_string($line['quantity_unit'], $asset->assetType->measuring_units));
            ?>
</td>
					<td>
						<?php 
            if ($expedition->statut != 1) {
                echo '<a href="?action=DELETE_LINE&k=' . $k . '&id=' . $expedition->id . '&rowid=' . $Trowid[0] . '">' . img_delete() . '</a>';
            }
            ?>
					</td>
				</tr>
				
				<?php 
        }
    }
    ?>
			
		
	</table>
	<br>
	<?php 
}
print '<td>';
print $formproduct->selectWarehouses($id_tw, 'id_tw', '', 1);
print '</td>';
// Qty
print '<td align="center"><input type="text" size="4" class="flat" name="qty" value="' . $qty . '"></td>';
// Button to add line
print '<td align="right"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($titletoadd) . '"></td>';
print '</tr>';
foreach ($listofdata as $key => $val) {
    $var = !$var;
    $productstatic->fetch($val['id_product']);
    $warehousestatics->fetch($val['id_sw']);
    $warehousestatict->fetch($val['id_tw']);
    print '<tr ' . $bc[$var] . '>';
    print '<td>';
    print $productstatic->getNomUrl(1) . ' - ' . $productstatic->label;
    print '</td>';
    if ($conf->productbatch->enabled) {
        print '<td>';
        print $val['batch'];
        print '</td>';
    }
    print '<td>';
    print $warehousestatics->getNomUrl(1);
    print '</td>';
    print '<td>';
    print $warehousestatict->getNomUrl(1);
    print '</td>';
    print '<td align="center">' . $val['qty'] . '</td>';
    print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=delline&idline=' . $val['id'] . '">' . img_delete($langs->trans("Remove")) . '</a></td>';
    print '</tr>';
Example #13
0
			print "<tr $bc[$var]>";
			if ($id > 0) {
				print '<td>';
				$invoicestatic->id=$objp->facid;
				$invoicestatic->ref=$objp->facnumber;
				print $invoicestatic->getNomUrl(1);
				print "</td>\n";
				print "<td align=\"center\">";
				print dol_print_date($db->jdate($objp->datef),'day')."</td>";
			}
			else {
				$product_static->type=$objp->fk_product_type;
				$product_static->id=$objp->fk_product;
				$product_static->ref=$objp->ref;
				$product_static->libelle=$objp->label;
				$text=$product_static->getNomUrl(1);
				$text.= ' - '.$objp->label;
				print "<td>".$product_static->getNomUrl(1)."</td>\n";
			}
			print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
			print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
			print "<td align=\"right\">".price($objp->marge)."</td>\n";
			if (! empty($conf->global->DISPLAY_MARGIN_RATES))
				print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
			if (! empty($conf->global->DISPLAY_MARK_RATES))
				print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
			print "</tr>\n";
			$i++;
			$cumul_achat += $objp->buying_price;
			$cumul_vente += $objp->selling_price;
		}
Example #14
0
 /**
  * 	Return HTML with a line of table array of source object lines
  *  TODO Move this and previous function into output html class file (htmlline.class.php).
  *  If lines are into a template, title must also be into a template
  *  But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
  * 	@param		line
  * 	@param		var
  */
 function printOriginLine($line, $var)
 {
     global $langs, $bc;
     //var_dump($line);
     $date_start = $line->date_debut_prevue;
     if ($line->date_debut_reel) {
         $date_start = $line->date_debut_reel;
     }
     $date_end = $line->date_fin_prevue;
     if ($line->date_fin_reel) {
         $date_end = $line->date_fin_reel;
     }
     $this->tpl['label'] = '';
     if (!empty($line->fk_parent_line)) {
         $this->tpl['label'] .= img_picto('', 'rightarrow');
     }
     if (($line->info_bits & 2) == 2) {
         $discount = new DiscountAbsolute($db);
         $discount->fk_soc = $this->socid;
         $this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
     } else {
         if ($line->fk_product) {
             $productstatic = new Product($this->db);
             $productstatic->id = $line->fk_product;
             $productstatic->ref = $line->ref;
             $productstatic->type = $line->fk_product_type;
             $this->tpl['label'] .= $productstatic->getNomUrl(1);
             $this->tpl['label'] .= $line->label ? ' - ' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         } else {
             $this->tpl['label'] .= $line->product_type == -1 ? '&nbsp;' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product'));
             $this->tpl['label'] .= $line->label ? '&nbsp;' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         }
     }
     if ($line->desc) {
         if ($line->desc == '(CREDIT_NOTE)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
         } elseif ($line->desc == '(DEPOSIT)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
         } else {
             $this->tpl['description'] = dol_trunc($line->desc, 60);
         }
     } else {
         $this->tpl['description'] = '&nbsp;';
     }
     $this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
     $this->tpl['price'] = price($line->subprice);
     $this->tpl['qty'] = ($line->info_bits & 2) != 2 ? $line->qty : '&nbsp;';
     $this->tpl['remise_percent'] = ($line->info_bits & 2) != 2 ? vatrate($line->remise_percent, true) : '&nbsp;';
     include DOL_DOCUMENT_ROOT . '/core/tpl/originproductline.tpl.php';
 }
function fiche_preview(&$object, &$TData)
{
    global $langs, $user, $db, $conf;
    //var_dump($_REQUEST);exit;
    $origin = GETPOST('origin');
    $head = null;
    if ($object->element == 'propal') {
        $head = propal_prepare_head($object);
    } else {
        $head = commande_prepare_head($object);
    }
    if (empty($user->rights->importdevis->myactions)) {
        accessforbidden();
        exit;
    }
    $form = new Form($db);
    llxHeader();
    $title = $langs->trans('Import');
    if ($origin == 'propal') {
        dol_fiche_head($head, 'importdevis', $title, 0, 'propal');
    } else {
        dol_fiche_head($head, 'importdevis', $title, 0, 'commande');
    }
    ?>
		<style type="text/css">
			#table_before_import tr.title_line td.for_line > * {
				display:none;
			}
			
			#table_before_import tr.line_line td.for_title > * {
				display:none;
			}
			
			.for_line select{
				white-space:normal;
				width:300px;
			}
			.ui-dialog {
			    overflow: visible !important;  /* or 'visible' whatever */
			}
		</style>
		
		<script type="text/javascript">
			$(function() {
				var old_type;
				
				$('#to_parse .type select').unbind().click(function() { old_type = $(this).val(); }).change(function() {
					switchClass($(this));
				});
				
				$( "#pop-edit-product-link" ).dialog({
			      modal: true,
			      autoOpen: false,
			      title:"Lier un produit à cette ligne",
			      buttons: {
			        "Lier ce produit": function() {
			        	
			          var fk_product = $('#fk_product_to_link').val() ;
			          var k = $(this).attr('k');	
			          $input = $('tr[k='+k+'] input[rel=fk_product]');
			         //console.log($input);
			         
			          $.ajax({
			          	url:"<?php 
    echo dol_buildpath('/product/ajax/products.php', 1);
    ?>
?action=fetch&id="+fk_product
			          	,dataType:'json'
			          }).done(function(product) {
			          	
			          	$('span[rel="ref-product"][k='+k+']').html(product.ref);
			          	$input.val(fk_product);
			          	console.log(product);
			          	
			          });
			        		
			          $( this ).dialog( "close" );
			        }
			      }
			    });
				
				function switchClass(element)
				{
					var type_value = $(element).val();
	
					if (type_value == 'title') 
					{
						$(element).parent().parent().addClass('liste_titre title_line');
						$(element).parent().parent().removeClass('line_line');
					}
					else 
					{
						$(element).parent().parent().addClass('line_line');
						$(element).parent().parent().removeClass('liste_titre title_line');
						
						if (old_type == 'title' && type_value == 'line')
						{
							while (element.length > 0)
							{
								element = $(element).parent().parent().next().find('td.type').children('select');
								
								if (element.val() == 'title') break;
								
								element.children('option[value=nomenclature]').attr('selected', true);
							}
							
						}
					}
				}
			});
			
			var imp_is_all_check = true;
			function checkAndUncheckAllImport()
			{
				if (imp_is_all_check)
				{
					imp_is_all_check = false;
					$("#to_parse tr .check_imp").attr('checked', false).prop('checked', false);
				}
				else
				{
					imp_is_all_check = true;
					$("#to_parse tr .check_imp").attr('checked', true).prop('checked', true);
				}
			}
			
			function edit_product_link(k) {
				$div = $('#pop-edit-product-link');
				$div.attr('k', k);
				
				$div.dialog('open');
			}
			
		</script>
		<div id="pop-edit-product-link" class="ui-dialog"  >
			<?php 
    $form->select_produits('', 'fk_product_to_link');
    ?>
		</div>
		<table id="table_before_import" width="100%" class="border">
			<tr>
				<td width="25%"><?php 
    echo $langs->trans('Ref');
    ?>
</td>
				<td colspan="3"><div style="vertical-align: middle"><div class="inline-block floatleft refid"><?php 
    echo $object->ref;
    ?>
</div></div></td>
			</tr>
			<tr>
				<td><?php 
    echo $langs->trans('Company');
    ?>
</td>MO-1
				<td colspan="3"><?php 
    echo $object->thirdparty->getNomUrl(1);
    ?>
</td>
			</tr>
			<tr>
				<td colspan="4">
					
						<?php 
    $PDOdb = new TPDOdb();
    $formCore = new TFormCore('auto', 'to_parse', 'post');
    echo $formCore->hidden('action', 'import_data');
    echo $formCore->hidden('id', $object->id);
    echo $formCore->hidden('origin', $origin);
    echo $formCore->hidden('token', $_SESSION['newtoken']);
    echo $formCore->hidden('data', base64_encode(serialize($TData)));
    ?>
							<table class="border" width="100%">
								<tr class="liste_titre">
									<th onclick="javascript:checkAndUncheckAllImport();" style="cursor:pointer;" title="sélectionner/désélectionner tous">Imp.</th>
									<th>Type</th>
									<?php 
    if ($conf->subtotal->enabled) {
        ?>
<th>Niveau</th><?php 
    }
    ?>
									<th>Produit</th>
									<th>Label</th>
									<th>Qté</th>
									<?php 
    if (!empty($conf->global->PRODUCT_USE_UNITS)) {
        ?>
<th>Unité</th><?php 
    }
    ?>
									<th>Prix Achat</th>
									<th>Prix</th>
									<?php 
    if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
        ?>
									<th>Ligne d'origine</th>
									<?php 
    }
    ?>
								</tr>
							<?php 
    if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
        $TPropalDet = array();
        foreach ($object->lines as $line) {
            $label = !empty($line->label) ? $line->label : $line->desc;
            $label .= ' (qté : ' . $line->qty . ', total HT : ' . $line->total_ht . ')';
            $TPropalDet[$line->id] = $label;
        }
    }
    $class = '';
    //var_dump($TData);
    $TWorkstation = TWorkstation::getWorstations($PDOdb);
    foreach ($TData as $k => &$row) {
        //var_dump($row);MO-1
        $workstation = new TWorkstation();
        //var_dump($workstation->loadBy($PDOdb, $row['workstation'], 'code'));
        //var_dump($workstation);exit;
        if (!empty($row['ref'])) {
            $res = $workstation->loadBy($PDOdb, $row['ref'], 'code');
            if ($res > 0) {
                $row['type'] = 'workstation';
                $id_workstation = $workstation->getId();
                //var_dump($workstation);
            }
        }
        $type = $row['type'];
        if ($type == 'title') {
            $class = '';
            print '<tr class="' . $class . ' liste_titre title_line">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            print '<td class="for_title">' . $form->selectarray('TData[' . $k . '][level]', getLevelTitle(), $row['level']) . '</td>';
            print '<td class="for_line">';
            //$form->select_produits(0, 'TData['.$k.'][fk_product]');
            print '</td>';
            print '<td>' . $formCore->texte('', 'TData[' . $k . '][label]', $row['label'], 50, 255) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line"></td>';
            }
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
        } elseif ($type == 'workstation') {
            //var_dump($type);
            $class = '';
            print '<tr class="' . $class . ' workstation_line">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            print '<td></td>';
            print '<td class="for_line">';
            echo $formCore->combo('', 'TData[' . $k . '][fk_workstation]', $TWorkstation, $id_workstation);
            print '</td>';
            print '<td>' . $row['workstation'] . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line"></td>';
            }
            print '<td></td>';
            print '<td></td>';
        } else {
            $class = $class == 'impair' ? 'pair' : 'impair';
            print '<tr class="line_line ' . $class . '" k="' . $k . '">';
            print '<td>' . $formCore->checkbox1('', 'TData[' . $k . '][to_import]', 1, true, '', 'check_imp') . '</td>';
            print '<td class="type">' . $form->selectarray('TData[' . $k . '][type]', getTypeLine(), $row['type']) . '</td>';
            if ($conf->subtotal->enabled) {
                print '<td class="for_title">' . $form->selectarray('TData[' . $k . '][level]', getLevelTitle(), $row['level']) . '</td>';
            }
            print '<td class="for_line">';
            if (!empty($row['product_ref'])) {
                $p = new Product($db);
                $p->fetch(null, $row['product_ref']);
                $fk_product = $p->id;
            } else {
                $fk_product = 0;
            }
            print '<span rel="ref-product" k="' . $k . '">' . ($fk_product > 0 ? $p->getNomUrl(1) : 'N/A') . '</span> <a href="javascript:edit_product_link(' . $k . ')">' . img_edit('Changer le produit de destination') . '</a>';
            //$form->select_produits($fk_product, 'TData['.$k.'][fk_product]');
            echo $formCore->hidden('TData[' . $k . '][fk_product]', $fk_product, ' rel="fk_product" ');
            echo $formCore->hidden('TData[' . $k . '][product_ref]', $row['product_ref'], ' rel="product_ref" ');
            print '</td>';
            print '<td>' . $formCore->texte('', 'TData[' . $k . '][label]', $row['label'], 80, 255);
            print '<table>';
            print '<tr>';
            print '<td>Longueur : ' . $formCore->texte('', 'TData[' . $k . '][length]', $row['length'], 15, 255) . '</td>';
            print '<td>Largeur : ' . $formCore->texte('', 'TData[' . $k . '][width]', $row['width'], 15, 255) . '</td>';
            print '<td>Hauteur : ' . $formCore->texte('', 'TData[' . $k . '][height]', $row['height'], 15, 255) . '</td>';
            print '<td>Poids : ' . $formCore->texte('', 'TData[' . $k . '][weight]', $row['weight'], 15, 255) . '</td>';
            print '</tr>';
            print '</table>';
            print '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][qty]', $row['qty'], 3, 20) . '</td>';
            if (!empty($conf->global->PRODUCT_USE_UNITS)) {
                print '<td class="for_line">' . $form->selectUnits($row['fk_unit'], 'TData[' . $k . '][fk_unit]', 1) . '</td>';
            }
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][buy_price]', $row['buy_price'], 10, 20) . '</td>';
            print '<td class="for_line">' . $formCore->texte('', 'TData[' . $k . '][price]', $row['price'], 10, 20) . '</td>';
        }
        if (!empty($conf->global->IMPORTPROPAL_USE_MAJ_ON_NOMENCLATURE)) {
            print '<td class="for_line">' . $form->selectarray('TData[' . $k . '][fk_propaldet]', $TPropalDet, '', 1) . '</td>';
        }
        print '</tr>';
    }
    //exit;
    ?>
							</table>
							<div class="tabsAction">
								<?php 
    echo $langs->trans('DeleteLinesBeforeImport');
    ?>
 <input id="delete_lines_before_import" name="delete_lines_before_import" type="checkbox" value="1" />
								<input class="button" type="submit" value="<?php 
    echo $langs->trans('Import');
    ?>
" />
							</div>
							<?php 
    $formCore->end();
    ?>
				</td>
			</tr>
		</table>
	<?php 
    dol_fiche_end();
    llxFooter();
}
/**
 * List sendings and receive receipts
 *
 * @param   string		$origin			Origin ('commande', ...)
 * @param	int			$origin_id		Origin id
 * @param	string		$filter			Filter
 * @return	int							<0 if KO, >0 if OK
 */
function show_list_sending_receive($origin, $origin_id, $filter = '')
{
    global $db, $conf, $langs, $bc;
    global $form;
    $product_static = new Product($db);
    $expedition = new Expedition($db);
    $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end";
    $sql .= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line";
    $sql .= ", e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
    //if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
    $sql .= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
    $sql .= ' p.description as product_desc';
    $sql .= " FROM " . MAIN_DB_PREFIX . "expeditiondet as ed";
    $sql .= ", " . MAIN_DB_PREFIX . "expedition as e";
    $sql .= ", " . MAIN_DB_PREFIX . $origin . "det as obj";
    //if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid  AND obj.rowid = ld.fk_origin_line";
    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON obj.fk_product = p.rowid";
    $sql .= " WHERE e.entity = " . $conf->entity;
    $sql .= " AND obj.fk_" . $origin . " = " . $origin_id;
    $sql .= " AND obj.rowid = ed.fk_origin_line";
    $sql .= " AND ed.fk_expedition = e.rowid";
    if ($filter) {
        $sql .= $filter;
    }
    $sql .= " ORDER BY obj.fk_product";
    dol_syslog("show_list_sending_receive sql=" . $sql, LOG_DEBUG);
    $resql = $db->query($sql);
    if ($resql) {
        $num = $db->num_rows($resql);
        $i = 0;
        if ($num) {
            if ($filter) {
                print_titre($langs->trans("OtherSendingsForSameOrder"));
            } else {
                print_titre($langs->trans("SendingsAndReceivingForSameOrder"));
            }
            print '<table class="liste" width="100%">';
            print '<tr class="liste_titre">';
            //print '<td align="left">'.$langs->trans("QtyOrdered").'</td>';
            print '<td align="left">' . $langs->trans("SendingSheet") . '</td>';
            print '<td align="left">' . $langs->trans("Description") . '</td>';
            print '<td align="center">' . $langs->trans("DateCreation") . '</td>';
            print '<td align="center">' . $langs->trans("DateDeliveryPlanned") . '</td>';
            print '<td align="center">' . $langs->trans("QtyShipped") . '</td>';
            if ($conf->livraison_bon->enabled) {
                print '<td>' . $langs->trans("DeliveryOrder") . '</td>';
                //print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
                print '<td align="right">' . $langs->trans("DeliveryDate") . '</td>';
            }
            print "</tr>\n";
            $var = True;
            while ($i < $num) {
                $var = !$var;
                $objp = $db->fetch_object($resql);
                print "<tr " . $bc[$var] . ">";
                // Sending id
                print '<td align="left" class="nowrap"><a href="' . DOL_URL_ROOT . '/expedition/fiche.php?id=' . $objp->expedition_id . '">' . img_object($langs->trans("ShowSending"), 'sending') . ' ' . $objp->exp_ref . '<a></td>';
                // Description
                if ($objp->fk_product > 0) {
                    // Define output language
                    if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
                        $object = new $origin($db);
                        $object->fetch($origin_id);
                        $object->fetch_thirdparty();
                        $prod = new Product($db);
                        $prod->id = $objp->fk_product;
                        $prod->getMultiLangs();
                        $outputlangs = $langs;
                        $newlang = '';
                        if (empty($newlang) && !empty($_REQUEST['lang_id'])) {
                            $newlang = $_REQUEST['lang_id'];
                        }
                        if (empty($newlang)) {
                            $newlang = $object->client->default_lang;
                        }
                        if (!empty($newlang)) {
                            $outputlangs = new Translate("", $conf);
                            $outputlangs->setDefaultLang($newlang);
                        }
                        $label = !empty($prod->multilangs[$outputlangs->defaultlang]["label"]) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label;
                    } else {
                        $label = !empty($objp->label) ? $objp->label : $objp->product_label;
                    }
                    print '<td>';
                    // Show product and description
                    $product_static->type = $objp->fk_product_type;
                    $product_static->id = $objp->fk_product;
                    $product_static->ref = $objp->ref;
                    $text = $product_static->getNomUrl(1);
                    $text .= ' - ' . $label;
                    $description = !empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($objp->description);
                    print $form->textwithtooltip($text, $description, 3, '', '', $i);
                    // Show range
                    print_date_range($objp->date_start, $objp->date_end);
                    // Add description in form
                    if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
                        print !empty($objp->description) && $objp->description != $objp->product ? '<br>' . dol_htmlentitiesbr($objp->description) : '';
                    }
                    print '</td>';
                } else {
                    print "<td>";
                    if ($objp->fk_product_type == 1) {
                        $text = img_object($langs->trans('Service'), 'service');
                    } else {
                        $text = img_object($langs->trans('Product'), 'product');
                    }
                    if (!empty($objp->label)) {
                        $text .= ' <strong>' . $objp->label . '</strong>';
                        print $form->textwithtooltip($text, $objp->description, 3, '', '', $i);
                    } else {
                        print $text . ' ' . nl2br($objp->description);
                    }
                    // Show range
                    print_date_range($objp->date_start, $objp->date_end);
                    print "</td>\n";
                }
                //print '<td align="center">'.$objp->qty_asked.'</td>';
                // Date creation
                print '<td align="center" class="nowrap">' . dol_print_date($db->jdate($objp->date_creation), 'day') . '</td>';
                // Date shipping creation
                print '<td align="center" class="nowrap">' . dol_print_date($db->jdate($objp->date_delivery), 'day') . '</td>';
                // Qty shipped
                print '<td align="center">' . $objp->qty_shipped . '</td>';
                // Informations on receipt
                if (!empty($conf->livraison_bon->enabled)) {
                    include_once DOL_DOCUMENT_ROOT . '/livraison/class/livraison.class.php';
                    $expedition->id = $objp->sendingid;
                    $expedition->fetchObjectLinked($expedition->id, $expedition->element);
                    //var_dump($expedition->linkedObjects);
                    $receiving = !empty($expedition->linkedObjects['delivery'][0]) ? $expedition->linkedObjects['delivery'][0] : '';
                    if (!empty($receiving)) {
                        // $expedition->fk_origin_line = id of det line of order
                        // $receiving->fk_origin_line = id of det line of order
                        // $receiving->origin may be 'shipping'
                        // $receiving->origin_id may be id of shipping
                        // Ref
                        print '<td>';
                        print $receiving->getNomUrl($db);
                        //print '<a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>';
                        print '</td>';
                        // Qty received
                        //print '<td align="center">';
                        // TODO No solution for the moment to link a line det of receipt with a line det of shipping,
                        // so no way to know the qty received for this line of shipping.
                        //print $langs->trans("FeatureNotYetAvailable");
                        //print '</td>';
                        // Date shipping real
                        print '<td align="right">';
                        print dol_print_date($receiving->date_delivery, 'day');
                        print '</td>';
                    } else {
                        //print '<td>&nbsp;</td>';
                        print '<td>&nbsp;</td>';
                        print '<td>&nbsp;</td>';
                    }
                }
                print '</tr>';
                $i++;
            }
            print '</table>';
        }
        $db->free($resql);
    } else {
        dol_print_error($db);
    }
    return 1;
}
Example #17
0
         print ' (';
         if (empty($object->fk_soc)) {
             print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
         }
         print $langs->trans("NoThirdPartyAssociatedToMember");
         print ' - <a href="' . $_SERVER["PHP_SELF"] . '?rowid=' . $object->id . '&amp;action=create_thirdparty">';
         print $langs->trans("CreateDolibarrThirdParty");
         print '</a>)';
     }
     if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') {
         print '. ' . $langs->trans("NoVatOnSubscription", 0);
     }
     if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
         $prodtmp = new Product($db);
         $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
         print '. ' . $langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1));
         // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
     }
     print '<br>';
 }
 print '</td></tr>';
 // Bank account
 print '<tr class="bankswitchclass"><td class="fieldrequired">' . $langs->trans("FinancialAccount") . '</td><td>';
 $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 1);
 print "</td></tr>\n";
 // Payment mode
 print '<tr class="bankswitchclass"><td class="fieldrequired">' . $langs->trans("PaymentMode") . '</td><td>';
 $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2);
 print "</td></tr>\n";
 // Date of payment
 print '<tr class="bankswitchclass"><td class="fieldrequired">' . $langs->trans("DatePayment") . '</td><td>';
Example #18
0
			if(sizeof($prods_arbo) > 0)
			{
				print '<tr><td colspan="2">';
				print '<b>'.$langs->trans("ProductAssociationList").'</b><br>';
				print '<table class="nobordernopadding">';
				foreach($prods_arbo as $value)
				{
					$productstatic->id=$value['id'];
					$productstatic->type=$value['type'];
					$productstatic->ref=$value['fullpath'];
					//var_dump($value);
					//print '<pre>'.$productstatic->ref.'</pre>';
					//print $productstatic->getNomUrl(1).'<br>';
					//print $value[0];	// This contains a tr line.
					print '<tr>';
					print '<td>'.$productstatic->getNomUrl(1).' ('.$value['nb'].')</td>';
					print '<td></td>';
					print '</tr>';
				}
				print '</table>';
				print '</td></tr>';
			}

			print "</table>\n";

			dol_fiche_end();
		}
	}

	/*
	 * Fiche en mode edition
Example #19
0
 if (!empty($conf->margin->enabled) && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) {
     print '<td width="50" align="right">' . $langs->trans("BuyingPrice") . '</td>';
 }
 print '<td width="30">&nbsp;</td>';
 print "</tr>\n";
 $objp = $db->fetch_object($result);
 $var = !$var;
 if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) {
     print '<tr ' . $bc[$var] . ' valign="top">';
     // Libelle
     if ($objp->fk_product > 0) {
         print '<td>';
         $productstatic->id = $objp->fk_product;
         $productstatic->type = $objp->ptype;
         $productstatic->ref = $objp->pref;
         $text = $productstatic->getNomUrl(1, '', 20);
         if ($objp->label) {
             $text .= ' - ';
             $productstatic->ref = $objp->label;
             $text .= $productstatic->getNomUrl(0, '', 16);
         }
         $description = $objp->description;
         // Add description in form
         if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
             $text .= !empty($objp->description) && $objp->description != $objp->product_label ? '<br>' . dol_htmlentitiesbr($objp->description) : '';
             $description = '';
             // Already added into main visible desc
         }
         echo $form->textwithtooltip($text, $description, 3, '', '', $cursorline, 0, !empty($line->fk_parent_line) ? img_picto('', 'rightarrow') : '');
         print '</td>';
     } else {
print $formproduct->selectWarehouses($id_tw, 'id_tw', '', 1);
print '</td>';
// Qty
print '<td align="center"><input type="text" size="4" class="flat" name="qty" value="' . $qty . '"></td>';
// Button to add line
if (!$listofdata) {
    print '<td align="right"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($titletoadd) . '"></td>';
}
print '</tr>';
foreach ($listofdata as $key => $val) {
    $var = !$var;
    $productstatic->fetch($val['id_product']);
    $warehousestatics->fetch($val['id_sw']);
    $warehousestatict->fetch($val['id_tw']);
    print '<tr ' . $bc[$var] . '>';
    print '<td>' . $productstatic->getNomUrl(1) . '</td>';
    print '<td>';
    $oldref = $productstatic->ref;
    $productstatic->ref = $productstatic->label;
    print $productstatic->getNomUrl(1);
    $productstatic->ref = $oldref;
    print '</td>';
    print '<td>';
    print $warehousestatics->getNomUrl(1);
    print '</td>';
    print '<td>';
    print $warehousestatict->getNomUrl(1);
    print '</td>';
    print '<td align="center">' . $val['qty'] . '</td>';
    print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=delline&idline=' . $val['id'] . '">' . img_delete($langs->trans("Remove")) . '</a></td>';
    print '</tr>';
Example #21
0
 print '<td>' . $langs->trans('ParentProduct') . '</td>';
 print '<td>' . $langs->trans('Label') . '</td>';
 print '<td>' . $langs->trans('Qty') . '</td>';
 print '</td>';
 if (count($prodsfather) > 0) {
     $class = 'pair';
     foreach ($prodsfather as $value) {
         $idprod = $value["id"];
         $productstatic->id = $idprod;
         // $value["id"];
         $productstatic->type = $value["fk_product_type"];
         $productstatic->ref = $value['ref'];
         $productstatic->label = $value['label'];
         $class = $class == 'impair' ? 'pair' : 'impair';
         print '<tr class="' . $class . '">';
         print '<td>' . $productstatic->getNomUrl(1, 'composition') . '</td>';
         print '<td>' . $productstatic->label . '</td>';
         print '<td>' . $value['qty'] . '</td>';
         print '</tr>';
     }
 } else {
     print '<tr class="impair">';
     print '<td colspan="3">' . $langs->trans("None") . '</td>';
     print '</tr>';
 }
 print '</table>';
 //}
 print '<br>' . "\n";
 // Number of subproducts
 //print $form->textwithpicto($langs->trans("AssociatedProductsNumber").': '.(empty($conf->global->PRODUCT_SHOW_SUB_SUB_PRODUCTS)?$nbofsubproducts:$nbofsubsubproducts), $langs->trans('IfZeroItIsNotAVirtualProduct'));
 // List of subproducts
Example #22
0
 /**
  * 	Return HTML with a line of table array of source object lines
  *  TODO Move this and previous function into output html class file (htmlline.class.php).
  *  If lines are into a template, title must also be into a template
  *  But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
  *
  * 	@param	array	$line		Line
  * 	@param	string	$var		Var
  * 	@return	void
  */
 function printOriginLine($line, $var)
 {
     global $conf, $langs, $bc;
     //var_dump($line);
     $date_start = $line->date_debut_prevue;
     if ($line->date_debut_reel) {
         $date_start = $line->date_debut_reel;
     }
     $date_end = $line->date_fin_prevue;
     if ($line->date_fin_reel) {
         $date_end = $line->date_fin_reel;
     }
     $this->tpl['label'] = '';
     if (!empty($line->fk_parent_line)) {
         $this->tpl['label'] .= img_picto('', 'rightarrow');
     }
     if (($line->info_bits & 2) == 2) {
         $discount = new DiscountAbsolute($this->db);
         $discount->fk_soc = $this->socid;
         $this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
     } else {
         if ($line->fk_product) {
             $productstatic = new Product($this->db);
             $productstatic->id = $line->fk_product;
             $productstatic->ref = $line->ref;
             $productstatic->type = $line->fk_product_type;
             $this->tpl['label'] .= $productstatic->getNomUrl(1);
             $this->tpl['label'] .= $line->label ? ' - ' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         } else {
             $this->tpl['label'] .= $line->product_type == -1 ? '&nbsp;' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product'));
             $this->tpl['label'] .= $line->label ? '&nbsp;' . $line->label : '';
             // Dates
             if ($line->product_type == 1 && ($date_start || $date_end)) {
                 $this->tpl['label'] .= get_date_range($date_start, $date_end);
             }
         }
     }
     if ($line->desc) {
         if ($line->desc == '(CREDIT_NOTE)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
         } elseif ($line->desc == '(DEPOSIT)') {
             $discount = new DiscountAbsolute($this->db);
             $discount->fetch($line->fk_remise_except);
             $this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
         } else {
             $this->tpl['description'] = dol_trunc($line->desc, 60);
         }
     } else {
         $this->tpl['description'] = '&nbsp;';
     }
     $this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
     $this->tpl['price'] = price($line->subprice);
     $this->tpl['qty'] = ($line->info_bits & 2) != 2 ? $line->qty : '&nbsp;';
     $this->tpl['remise_percent'] = ($line->info_bits & 2) != 2 ? vatrate($line->remise_percent, true) : '&nbsp;';
     // Output template part (modules that overwrite templates must declare this into descriptor)
     // Use global variables + $dateSelector + $seller and $buyer
     $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
     foreach ($dirtpls as $reldir) {
         $res = @(include dol_buildpath($reldir . '/originproductline.tpl.php'));
         if ($res) {
             break;
         }
     }
 }
Example #23
0
			if (! empty($objp->date_end)) $type=1;

			if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
			{
				print '<tr '.$bc[$var].'>';
				if ($objp->fk_product > 0)
				{
					print '<td>';
					print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne;

					// Show product and description
					$product_static->type=$objp->fk_product_type;
					$product_static->id=$objp->fk_product;
					$product_static->ref=$objp->ref;
					$product_static->libelle=$objp->product_label;
					$text=$product_static->getNomUrl(1);
					$text.= ' - '.$objp->product_label;
					$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
					print $html->textwithtooltip($text,$description,3,'','',$i);

					// Show range
					print_date_range($objp->date_start,$objp->date_end);

					// Add description in form
					if ($conf->global->PRODUIT_DESC_IN_FORM)
					{
						print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
					}
					print '</td>';
				}
				else
Example #24
0
}
$nav .= $form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
$nav .= ' <input type="submit" name="submitdateselect" class="button" value="' . $langs->trans("Refresh") . '">';
$nav .= '</form>';
print_barre_liste('Title of my list', 3, $_SERVER["PHP_SELF"], '', '', '', 'Text in middle', 20, 5000, '', 0, $nav);
?>
<table class="liste noborder tagtable centpercent" id="tablelines3">
<tr class="liste_titre">
<?php 
print getTitleFieldOfList($langs->trans('title1'), 0, $_SERVER["PHP_SELF"], 'aaa', '', '', 'align="left"', $sortfield, $sortorder);
print getTitleFieldOfList($langs->trans('title2'), 0, $_SERVER["PHP_SELF"], 'bbb', '', '', 'align="right"', $sortfield, $sortorder);
print getTitleFieldOfList($langs->trans('title3'), 0, $_SERVER["PHP_SELF"], 'ccc', '', '', 'align="center"', $sortfield, $sortorder);
?>
</tr>
<tr class="pair"><td><?php 
echo $productspecimen->getNomUrl(1);
?>
</td><td align="right">b1</td><td class="tdlineupdown" align="left">c1</td></tr>
<tr class="impair"><td>a2</td><td align="right">b2</td><td class="tdlineupdown" align="left">c2</td></tr>
</table>
<br>



<br><hr><br>Example 2 : Table using tags: table/thead/tbody/tr/th-td + dataTable => Use this for short result tables<br>



<script type="text/javascript">
$(document).ready(function(){
    $('#idtableexample2').dataTable( {
 print '<td>&nbsp;</td>';
 print '</tr>';
 print '<tr class="liste_titre">';
 print '<td><input type="text" class="flat" name="search_soc" value="' . $search_soc . '" size="20"></td>';
 print '<td colspan="8">&nbsp;</td>';
 // Print the search button
 print '<td class="liste_titre" align="right">';
 print '<input class="liste_titre" name="button_search" type="image" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 print '</td>';
 print '</tr>';
 $var = True;
 foreach ($prodcustprice->lines as $line) {
     print "<tr {$bc[$var]}>";
     $staticprod = new Product($db);
     $staticprod->fetch($line->fk_product);
     print "<td>" . $staticprod->getNomUrl(1) . "</td>";
     print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>";
     print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>";
     print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>";
     print '<td align="right">' . price($line->price) . "</td>";
     print '<td align="right">' . price($line->price_ttc) . "</td>";
     print '<td align="right">' . price($line->price_min) . '</td>';
     print '<td align="right">' . price($line->price_min_ttc) . '</td>';
     // User
     $userstatic = new User($db);
     $userstatic->fetch($line->fk_user);
     print '<td align="right">';
     print $userstatic->getLoginUrl(1);
     print '</td>';
     // Todo Edit or delete button
     // Action
Example #26
0
			{
				print '<tr><td colspan="2">';
				print '<b>'.$langs->trans("ProductAssociationList").'</b><br>';
				print '<table class="nobordernopadding">';
				foreach($prods_arbo as $value)
				{
					$productstatic->id=$value['id'];
					$productstatic->type=$value['type'];
					$productstatic->ref=$value['fullpath'];
					if ($conf->stock->enabled) $productstatic->load_stock();
					//var_dump($value);
					//print '<pre>'.$productstatic->ref.'</pre>';
					//print $productstatic->getNomUrl(1).'<br>';
					//print $value[0];	// This contains a tr line.
					print '<tr>';
					print '<td>'.$productstatic->getNomUrl(1,'composition').' ('.$value['nb'].') &nbsp &nbsp</td>';
					if ($conf->stock->enabled) print '<td>'.$langs->trans("Stock").' : <b>'.$productstatic->stock_reel.'</b></td>';
					print '</tr>';
				}
				print '</table>';
				print '</td></tr>';
			}

			// Number of parent products
			print '<tr><td>'.$langs->trans("ParentProductsNumber").'</td><td>'.count($prodsfather).'</td>';

			if (count($prodsfather) > 0)
			{
				print '<tr><td colspan="2">';
				print '<b>'.$langs->trans("ProductParentList").'</b><br>';
				print '<table class="nobordernopadding">';
 print '<td>' . '<input class="check" type="checkbox" rel="' . $objp->mid . '" ';
 if ($objp->checked > 0) {
     print 'checked';
 }
 print '></td>';
 // Label of movement
 print '<td>' . $objp->label . '</td>';
 // Checkpoint: eliminar la columna de origen
 // Origin of movement
 // print '<td>'.$origin.'</td>';
 // Product ref
 print '<td>';
 $productstatic->id = $objp->rowid;
 $productstatic->ref = $objp->product_ref;
 $productstatic->type = $objp->type;
 print $productstatic->getNomUrl(1, '', 16);
 print "</td>\n";
 // Product label
 print '<td>';
 $productstatic->id = $objp->rowid;
 $productstatic->ref = $objp->produit;
 $productstatic->type = $objp->type;
 print $productstatic->getNomUrl(1, '', 16);
 print "</td>\n";
 // Warehouse
 print '<td>';
 //if($entrepot_origen != '')
 //{
 $warehousestatic->id = $entrepot_id_origen;
 $warehousestatic->libelle = $entrepot_origen;
 //}
Example #28
0
		$var=!$var;
		$codeCompta = $objp->numero.' '.$objp->intitule;

		print "<tr $bc[$var]>";

		// Ref facture
		$facture_static->ref=$objp->facnumber;
		$facture_static->id=$objp->facid;
		print '<td>'.$facture_static->getNomUrl(1).'</td>';

		// Ref produit
		$product_static->ref=$objp->product_ref;
		$product_static->id=$objp->product_id;
		$product_static->type=$objp->type;
		print '<td>';
		if ($product_static->id) print $product_static->getNomUrl(1);
		else print '&nbsp;';
		print '</td>';

		print '<td>'.dol_trunc($objp->product_label,24).'</td>';
		print '<td>'.nl2br(dol_trunc($objp->description,32)).'</td>';
		print '<td align="left">'.price($objp->price).'</td>';
		print '<td align="left">'.$codeCompta.'</td>';

		print "</tr>";
		$i++;
	}
}
else
{
	print $db->error();
     $result = $db->query($sql);
     if ($result) {
         $objtp = $db->fetch_object($result);
         if ($objtp->label != '') {
             $objp->produit = $objtp->label;
         }
     }
 }
 $var = !$var;
 //print '<td>'.dol_print_date($objp->datem).'</td>';
 print "<tr " . $bc[$var] . ">";
 print "<td>";
 $productstatic->id = $objp->rowid;
 $productstatic->ref = $objp->ref;
 $productstatic->type = $objp->type;
 print $productstatic->getNomUrl(1, 'stock', 16);
 print '</td>';
 print '<td>' . $objp->produit . '</td>';
 print '<td align="right">' . $objp->value . '</td>';
 $totalunit += $objp->value;
 // Price buy PMP
 print '<td align="right">' . price(price2num($objp->pmp, 'MU')) . '</td>';
 // Total PMP
 print '<td align="right">' . price(price2num($objp->pmp * $objp->value, 'MT')) . '</td>';
 $totalvalue += price2num($objp->pmp * $objp->value, 'MT');
 // Price sell min
 if (empty($conf->global->PRODUIT_MULTIPRICES)) {
     $pricemin = $objp->price;
     print '<td align="right">';
     print price(price2num($pricemin, 'MU'), 1);
     print '</td>';
Example #30
0
	print '</tr>';
	print '</form>';

	$oldid = '';
	$var=True;
	while ($i < min($num,$limit))
	{
		$objp = $db->fetch_object($resql);
		$var=!$var;
		print "<tr $bc[$var]>";

		print '<td>';
		$productstatic->id=$objp->rowid;
		$productstatic->ref=$objp->ref;
		$productstatic->type=$objp->fk_product_type;
		print $productstatic->getNomUrl(1,'supplier');
		print '</td>';

		print '<td>'.$objp->ref_fourn.'</td>';

		print '<td>'.$objp->label.'</td>'."\n";

		$companystatic->nom=$objp->nom;
		$companystatic->id=$objp->socid;
		print '<td>'.$companystatic->getNomUrl(1,'supplier').'</td>';

		print '<td align="right">'.price($objp->price).'</td>';

		print '<td align="right">'.$objp->qty.'</td>';

		print '<td align="right">'.price($objp->unitprice).'</td>';