Use new banner for other tabs of product

This commit is contained in:
Laurent Destailleur 2015-11-07 13:32:14 +01:00
parent 439e4a483d
commit c0872d690e
9 changed files with 231 additions and 289 deletions

View File

@ -82,28 +82,13 @@ if ($id > 0 || ! empty($ref))
$picto=($object->type== Product::TYPE_SERVICE?'service':'product'); $picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'margin', $titre, 0, $picto); dol_fiche_head($head, 'margin', $titre, 0, $picto);
print '<table class="border" width="100%">'; dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
// Reference
print '<tr>'; print '<div class="fichecenter">';
print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($object,'ref','',1,'ref'); print '<div class="underbanner clearboth"></div>';
print '</td>'; print '<table class="border tableforfield" width="100%">';
print '</tr>';
// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->label.'</td>';
print '</tr>';
// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">';
print $object->getLibStatut(2,0);
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">';
print $object->getLibStatut(2,1);
print '</td></tr>';
// Total Margin // Total Margin
print '<tr><td>'.$langs->trans("TotalMargin").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("TotalMargin").'</td><td colspan="3">';
@ -125,7 +110,11 @@ if ($id > 0 || ! empty($ref))
} }
print "</table>"; print "</table>";
print '</div>';
print '</div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
if ($user->rights->facture->lire) { if ($user->rights->facture->lire) {

View File

@ -73,21 +73,21 @@ if ($socid > 0)
dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company'); dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company');
print '<table class="border" width="100%">'; dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
print '<tr><td width="20%">'.$langs->trans('ThirdPartyName').'</td>'; print '<div class="fichecenter">';
print '<td colspan="3">';
print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print '<div class="underbanner clearboth"></div>';
print '</td></tr>'; print '<table class="border tableforfield" width="100%">';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field // Alias names (commercial, trademark or alias names)
{ print '<tr><td class="titlefield">'.$langs->trans('AliasNames').'</td><td>';
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; print $object->name_alias;
} print "</td></tr>";
if ($object->client) if ($object->client)
{ {
print '<tr><td>'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">'; print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client; print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
@ -96,7 +96,7 @@ if ($socid > 0)
if ($object->fournisseur) if ($object->fournisseur)
{ {
print '<tr><td>'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur; print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
@ -104,7 +104,7 @@ if ($socid > 0)
} }
// Total Margin // Total Margin
print '<tr><td>'.$langs->trans("TotalMargin").'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans("TotalMargin").'</td><td colspan="3">';
print '<span id="totalMargin"></span>'; // set by jquery (see below) print '<span id="totalMargin"></span>'; // set by jquery (see below)
print '</td></tr>'; print '</td></tr>';
@ -123,7 +123,11 @@ if ($socid > 0)
} }
print "</table>"; print "</table>";
dol_fiche_end();
print '</div>'; print '</div>';
print '<div style="clear:both"></div>';
$sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,";

View File

@ -195,33 +195,21 @@ if ($object->id)
} }
print '<table class="border" width="100%">'; dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
// Ref print '<div class="fichecenter">';
print '<tr>';
print '<td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<div class="underbanner clearboth"></div>';
print $form->showrefnav($object,'ref','',1,'ref'); print '<table class="border tableforfield" width="100%">';
print '</td>';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$object->label.'</td></tr>';
// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
print $object->getLibStatut(2,0);
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>';
print $object->getLibStatut(2,1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
$modulepart = 'produit'; $modulepart = 'produit';
$permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));

View File

@ -264,21 +264,15 @@ if ($id > 0 || $ref)
$picto=($object->type== Product::TYPE_SERVICE?'service':'product'); $picto=($object->type== Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'suppliers', $titre, 0, $picto); dol_fiche_head($head, 'suppliers', $titre, 0, $picto);
dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
print '<table class="border" width="100%">';
print '<div class="fichecenter">';
// Reference
print '<tr>'; print '<div class="underbanner clearboth"></div>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">'; print '<table class="border tableforfield" width="100%">';
print $form->showrefnav($object,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->label.'</td></tr>';
// Minimum Price // Minimum Price
print '<tr><td>'.$langs->trans("BuyingPriceMin").'</td>'; print '<tr><td class="titlefield">'.$langs->trans("BuyingPriceMin").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
$product_fourn = new ProductFournisseur($db); $product_fourn = new ProductFournisseur($db);
if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0)
@ -288,14 +282,13 @@ if ($id > 0 || $ref)
} }
print '</td></tr>'; print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>';
print $object->getLibStatut(2,1);
print '</td></tr>';
print '</table>'; print '</table>';
print "</div>\n"; print '</div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
// Form to add or update a price // Form to add or update a price
if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer)) if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer))

View File

@ -402,34 +402,13 @@ $titre = $langs->trans("CardProduct" . $object->type);
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
dol_fiche_head($head, 'price', $titre, 0, $picto); dol_fiche_head($head, 'price', $titre, 0, $picto);
print '<table class="border" width="100%">'; dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
// Ref
print '<tr>';
print '<td width="20%">' . $langs->trans("Ref") . '</td><td colspan="2">';
print $form->showrefnav($object, 'ref', '', 1, 'ref');
print '</td>';
print '</tr>';
// Label print '<div class="fichecenter">';
print '<tr><td>' . $langs->trans("Label") . '</td><td colspan="2">' . $object->label . '</td>';
$isphoto = $object->is_photo_available($conf->product->multidir_output [$object->entity]); print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
$nblignes = 5;
if ($isphoto) {
// Photo
print '<td valign="middle" align="center" width="30%" rowspan="' . $nblignes . '">';
print $object->show_photos($conf->product->multidir_output [$object->entity], 1, 1, 0, 0, 0, 80);
print '</td>';
}
print '</tr>';
// Status (to sell)
print '<tr><td>' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')</td><td colspan="2">';
print $object->getLibStatut(2, 0);
print '</td></tr>';
// MultiPrix // MultiPrix
if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES))
@ -442,7 +421,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
$soc->fetch($socid); $soc->fetch($socid);
// Selling price // Selling price
print '<tr>' . $langs->trans("SellingPrice") . '</td>'; print '<tr><td class="titlefield">' . $langs->trans("SellingPrice") . '</td>';
print '<td colspan="2">'; print '<td colspan="2">';
if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') { if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') {
print price($object->multiprices_ttc["$soc->price_level"]); print price($object->multiprices_ttc["$soc->price_level"]);
@ -483,12 +462,12 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
{ {
// We show only vat for level 1 // We show only vat for level 1
print '<tr><td>' . $langs->trans("VATRate") . '</td><td colspan="2">' . vatrate($object->multiprices_tva_tx [1], true) . '</td></tr>'; print '<tr><td class="titlefield">' . $langs->trans("VATRate") . '</td><td colspan="2">' . vatrate($object->multiprices_tva_tx [1], true) . '</td></tr>';
} }
else else
{ {
// TVA // TVA
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '</td></tr>'; print '<tr><td class="titlefield">' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '</td></tr>';
} }
print '<tr class="liste_titre"><td style="text-align: center">'.$langs->trans("PriceLevel").'</td><td style="text-align: center">'.$langs->trans("SellingPrice").'</td><td style="text-align: center">'.$langs->trans("MinPrice").'</td></tr>'; print '<tr class="liste_titre"><td style="text-align: center">'.$langs->trans("PriceLevel").'</td><td style="text-align: center">'.$langs->trans("SellingPrice").'</td><td style="text-align: center">'.$langs->trans("MinPrice").'</td></tr>';
@ -605,7 +584,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
else else
{ {
// TVA // TVA
print '<tr><td>' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '</td></tr>'; print '<tr><td class="titlefield">' . $langs->trans("VATRate") . '</td><td>' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '</td></tr>';
// Price // Price
print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>'; print '<tr><td>' . $langs->trans("SellingPrice") . '</td><td>';
@ -703,6 +682,10 @@ else
print "</table>\n"; print "</table>\n";
print '</div>';
print '<div style="clear:both"></div>';
dol_fiche_end(); dol_fiche_end();

View File

@ -72,24 +72,24 @@ if ($cancel) $action='';
// Set stock limit // Set stock limit
if ($action == 'setstocklimit') if ($action == 'setstocklimit')
{ {
$product = new Product($db); $object = new Product($db);
$result=$product->fetch($id); $result=$object->fetch($id);
$product->seuil_stock_alerte=$stocklimit; $object->seuil_stock_alerte=$stocklimit;
$result=$product->update($product->id,$user,0,'update'); $result=$object->update($object->id,$user,0,'update');
if ($result < 0) if ($result < 0)
setEventMessage($product->error, 'errors'); setEventMessage($object->error, 'errors');
$action=''; $action='';
} }
// Set desired stock // Set desired stock
if ($action == 'setdesiredstock') if ($action == 'setdesiredstock')
{ {
$product = new Product($db); $object = new Product($db);
$result=$product->fetch($id); $result=$object->fetch($id);
$product->desiredstock=$desiredstock; $object->desiredstock=$desiredstock;
$result=$product->update($product->id,$user,0,'update'); $result=$object->update($object->id,$user,0,'update');
if ($result < 0) if ($result < 0)
setEventMessage($product->error, 'errors'); setEventMessage($object->error, 'errors');
$action=''; $action='';
} }
@ -112,10 +112,10 @@ if ($action == "correct_stock" && ! $cancel)
if (! empty($conf->productbatch->enabled)) if (! empty($conf->productbatch->enabled))
{ {
$product = new Product($db); $object = new Product($db);
$result=$product->fetch($id); $result=$object->fetch($id);
if ($product->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) { if ($object->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors');
$error++; $error++;
$action='correction'; $action='correction';
@ -127,13 +127,13 @@ if ($action == "correct_stock" && ! $cancel)
$priceunit=price2num(GETPOST("unitprice")); $priceunit=price2num(GETPOST("unitprice"));
if (is_numeric(GETPOST("nbpiece")) && $id) if (is_numeric(GETPOST("nbpiece")) && $id)
{ {
if (empty($product)) { if (empty($object)) {
$product = new Product($db); $object = new Product($db);
$result=$product->fetch($id); $result=$object->fetch($id);
} }
if ($product->hasbatch()) if ($object->hasbatch())
{ {
$result=$product->correct_stock_batch( $result=$object->correct_stock_batch(
$user, $user,
GETPOST("id_entrepot"), GETPOST("id_entrepot"),
GETPOST("nbpiece"), GETPOST("nbpiece"),
@ -148,7 +148,7 @@ if ($action == "correct_stock" && ! $cancel)
} }
else else
{ {
$result=$product->correct_stock( $result=$object->correct_stock(
$user, $user,
GETPOST("id_entrepot"), GETPOST("id_entrepot"),
GETPOST("nbpiece"), GETPOST("nbpiece"),
@ -168,13 +168,13 @@ if ($action == "correct_stock" && ! $cancel)
} }
else else
{ {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
exit; exit;
} }
} }
else else
{ {
setEventMessage($product->error,'errors'); setEventMessage($object->error,'errors');
$action='correction'; $action='correction';
} }
} }
@ -207,20 +207,20 @@ if ($action == "transfert_stock" && ! $cancel)
{ {
if ($id) if ($id)
{ {
$product = new Product($db); $object = new Product($db);
$result=$product->fetch($id); $result=$object->fetch($id);
$db->begin(); $db->begin();
$product->load_stock(); // Load array product->stock_warehouse $object->load_stock(); // Load array product->stock_warehouse
// Define value of products moved // Define value of products moved
$pricesrc=0; $pricesrc=0;
//if (isset($product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp; //if (isset($object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp;
if (isset($product->pmp)) $pricesrc=$product->pmp; if (isset($object->pmp)) $pricesrc=$object->pmp;
$pricedest=$pricesrc; $pricedest=$pricesrc;
if ($product->hasbatch()) if ($object->hasbatch())
{ {
$pdluo = new Productbatch($db); $pdluo = new Productbatch($db);
@ -251,7 +251,7 @@ if ($action == "transfert_stock" && ! $cancel)
if (! $error) if (! $error)
{ {
// Remove stock // Remove stock
$result1=$product->correct_stock_batch( $result1=$object->correct_stock_batch(
$user, $user,
$srcwarehouseid, $srcwarehouseid,
GETPOST("nbpiece",'int'), GETPOST("nbpiece",'int'),
@ -262,7 +262,7 @@ if ($action == "transfert_stock" && ! $cancel)
GETPOST('inventorycode') GETPOST('inventorycode')
); );
// Add stock // Add stock
$result2=$product->correct_stock_batch( $result2=$object->correct_stock_batch(
$user, $user,
GETPOST("id_entrepot_destination",'int'), GETPOST("id_entrepot_destination",'int'),
GETPOST("nbpiece",'int'), GETPOST("nbpiece",'int'),
@ -277,7 +277,7 @@ if ($action == "transfert_stock" && ! $cancel)
else else
{ {
// Remove stock // Remove stock
$result1=$product->correct_stock( $result1=$object->correct_stock(
$user, $user,
GETPOST("id_entrepot_source"), GETPOST("id_entrepot_source"),
GETPOST("nbpiece"), GETPOST("nbpiece"),
@ -288,7 +288,7 @@ if ($action == "transfert_stock" && ! $cancel)
); );
// Add stock // Add stock
$result2=$product->correct_stock( $result2=$object->correct_stock(
$user, $user,
GETPOST("id_entrepot_destination"), GETPOST("id_entrepot_destination"),
GETPOST("nbpiece"), GETPOST("nbpiece"),
@ -309,13 +309,13 @@ if ($action == "transfert_stock" && ! $cancel)
} }
else else
{ {
header("Location: product.php?id=".$product->id); header("Location: product.php?id=".$object->id);
exit; exit;
} }
} }
else else
{ {
setEventMessages($product->error, $product->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$db->rollback(); $db->rollback();
$action='transfert'; $action='transfert';
} }
@ -370,70 +370,45 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save'))
* View * View
*/ */
$form = new Form($db);
$formproduct=new FormProduct($db); $formproduct=new FormProduct($db);
if ($id > 0 || $ref) if ($id > 0 || $ref)
{ {
$product = new Product($db); $object = new Product($db);
$result = $product->fetch($id,$ref); $result = $object->fetch($id,$ref);
$product->load_stock(); $object->load_stock();
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks'; $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
llxHeader("",$langs->trans("CardProduct".$product->type),$help_url); llxHeader("",$langs->trans("CardProduct".$object->type),$help_url);
if ($result > 0) if ($result > 0)
{ {
$head=product_prepare_head($product); $head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($product->type==Product::TYPE_SERVICE?'service':'product'); $picto=($object->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'stock', $titre, 0, $picto); dol_fiche_head($head, 'stock', $titre, 0, $picto);
dol_htmloutput_events(); dol_htmloutput_events();
$form = new Form($db); dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
print '<table class="border" width="100%">'; print '<div class="fichecenter">';
// Ref print '<div class="underbanner clearboth"></div>';
print '<tr>'; print '<table class="border tableforfield" width="100%">';
print '<td width="30%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($product,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->label.'</td>';
print '</tr>';
// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($product, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
} else {
print $product->getLibStatut(2,0);
}
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="2">';
if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
print ajax_object_onoff($product, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
} else {
print $product->getLibStatut(2,1);
}
print '</td></tr>';
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled) {
print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td>'; print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td>';
print $product->getLibStatut(0,2); print $object->getLibStatut(0,2);
print '</td></tr>'; print '</td></tr>';
} }
// PMP // PMP
print '<tr><td>'.$langs->trans("AverageUnitPricePMP").'</td>'; print '<tr><td>'.$langs->trans("AverageUnitPricePMP").'</td>';
print '<td>'; print '<td>';
if ($product->pmp > 0) print price($product->pmp).' '.$langs->trans("HT"); if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -441,14 +416,13 @@ if ($id > 0 || $ref)
print '<tr><td>'.$langs->trans("BuyingPriceMin").'</td>'; print '<tr><td>'.$langs->trans("BuyingPriceMin").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
$product_fourn = new ProductFournisseur($db); $product_fourn = new ProductFournisseur($db);
if ($product_fourn->find_min_price_product_fournisseur($product->id) > 0) if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0)
{ {
if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(); if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur();
else print $langs->trans("NotDefined"); else print $langs->trans("NotDefined");
} }
print '</td></tr>'; print '</td></tr>';
$object = $product;
if (empty($conf->global->PRODUIT_MULTIPRICES)) if (empty($conf->global->PRODUIT_MULTIPRICES))
{ {
// Price // Price
@ -483,17 +457,17 @@ if ($id > 0 || $ref)
} }
// Stock alert threshold // Stock alert threshold
print '<tr><td>'.$form->editfieldkey("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer).'</td><td colspan="2">'; print '<tr><td>'.$form->editfieldkey("StockLimit",'stocklimit',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td colspan="2">';
print $form->editfieldval("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer); print $form->editfieldval("StockLimit",'stocklimit',$object->seuil_stock_alerte,$object,$user->rights->produit->creer);
print '</td></tr>'; print '</td></tr>';
// Desired stock // Desired stock
print '<tr><td>'.$form->editfieldkey("DesiredStock",'desiredstock',$product->desiredstock,$product,$user->rights->produit->creer).'</td><td colspan="2">'; print '<tr><td>'.$form->editfieldkey("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer).'</td><td colspan="2">';
print $form->editfieldval("DesiredStock",'desiredstock',$product->desiredstock,$product,$user->rights->produit->creer); print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer);
print '</td></tr>'; print '</td></tr>';
// Real stock // Real stock
$product->load_stock(); $object->load_stock();
$text_stock_options = ''; $text_stock_options = '';
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'<br>':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'<br>':'');
$text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'<br>':'');
@ -504,15 +478,15 @@ if ($id > 0 || $ref)
print '<tr><td>'; print '<tr><td>';
print $form->textwithtooltip($langs->trans("PhysicalStock"), $text_stock_options, 2, 1, img_picto('', 'info'), '', 2); print $form->textwithtooltip($langs->trans("PhysicalStock"), $text_stock_options, 2, 1, img_picto('', 'info'), '', 2);
print '</td>'; print '</td>';
print '<td>'.$product->stock_reel; print '<td>'.$object->stock_reel;
if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit")); if ($object->seuil_stock_alerte && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit"));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Calculating a theorical value // Calculating a theorical value
print '<tr><td>'.$langs->trans("VirtualStock").'</td>'; print '<tr><td>'.$langs->trans("VirtualStock").'</td>';
print "<td>".(empty($product->stock_theorique)?0:$product->stock_theorique); print "<td>".(empty($object->stock_theorique)?0:$object->stock_theorique);
if ($product->stock_theorique < $product->seuil_stock_alerte) { if ($object->stock_theorique < $object->seuil_stock_alerte) {
print ' '.img_warning($langs->trans("StockLowerThanLimit")); print ' '.img_warning($langs->trans("StockLowerThanLimit"));
} }
print '</td>'; print '</td>';
@ -528,36 +502,36 @@ if ($id > 0 || $ref)
if (! empty($conf->commande->enabled)) if (! empty($conf->commande->enabled))
{ {
if ($found) print '<br>'; else $found=1; if ($found) print '<br>'; else $found=1;
print $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$product->stats_commande['qty']; print $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty'];
$result=$product->load_stats_commande(0,'0'); $result=$object->load_stats_commande(0,'0');
if ($result < 0) dol_print_error($db,$product->error); if ($result < 0) dol_print_error($db,$object->error);
print ' ('.$langs->trans("ProductQtyInDraft").': '.$product->stats_commande['qty'].')'; print ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')';
} }
// Number of product from customer order already sent (partial shipping) // Number of product from customer order already sent (partial shipping)
if (! empty($conf->expedition->enabled)) if (! empty($conf->expedition->enabled))
{ {
if ($found) print '<br>'; else $found=1; if ($found) print '<br>'; else $found=1;
$result=$product->load_stats_sending(0,'2'); $result=$object->load_stats_sending(0,'2');
print $langs->trans("ProductQtyInShipmentAlreadySent").': '.$product->stats_expedition['qty']; print $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty'];
} }
// Number of supplier order running // Number of supplier order running
if (! empty($conf->fournisseur->enabled)) if (! empty($conf->fournisseur->enabled))
{ {
if ($found) print '<br>'; else $found=1; if ($found) print '<br>'; else $found=1;
$result=$product->load_stats_commande_fournisseur(0,'3,4'); $result=$object->load_stats_commande_fournisseur(0,'3,4');
print $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$product->stats_commande_fournisseur['qty']; print $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty'];
$result=$product->load_stats_commande_fournisseur(0,'0,1,2'); $result=$object->load_stats_commande_fournisseur(0,'0,1,2');
if ($result < 0) dol_print_error($db,$product->error); if ($result < 0) dol_print_error($db,$object->error);
print ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')'; print ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')';
} }
// Number of product from supplier order already received (partial receipt) // Number of product from supplier order already received (partial receipt)
if (! empty($conf->fournisseur->enabled)) if (! empty($conf->fournisseur->enabled))
{ {
if ($found) print '<br>'; else $found=1; if ($found) print '<br>'; else $found=1;
print $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$product->stats_reception['qty']; print $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty'];
} }
print '</td></tr>'; print '</td></tr>';
@ -565,7 +539,7 @@ if ($id > 0 || $ref)
// Last movement // Last movement
$sql = "SELECT max(m.datem) as datem"; $sql = "SELECT max(m.datem) as datem";
$sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
$sql.= " WHERE m.fk_product = '".$product->id."'"; $sql.= " WHERE m.fk_product = '".$object->id."'";
$resqlbis = $db->query($sql); $resqlbis = $db->query($sql);
if ($resqlbis) if ($resqlbis)
{ {
@ -580,18 +554,21 @@ if ($id > 0 || $ref)
if ($lastmovementdate) if ($lastmovementdate)
{ {
print dol_print_date($lastmovementdate,'dayhour').' '; print dol_print_date($lastmovementdate,'dayhour').' ';
print '(<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$product->id.'">'.$langs->trans("FullList").'</a>)'; print '(<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("FullList").'</a>)';
} }
else else
{ {
print '<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$product->id.'">'.$langs->trans("None").'</a>'; print '<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?idproduct='.$object->id.'">'.$langs->trans("None").'</a>';
} }
print "</td></tr>"; print "</td></tr>";
print "</table>"; print "</table>";
print '</div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
} }
print '</div>';
/* /*
* Correct stock * Correct stock
@ -618,7 +595,7 @@ if ($id > 0 || $ref)
if ($_GET["action"] == "definir") if ($_GET["action"] == "definir")
{ {
print load_fiche_titre($langs->trans("SetStock")); print load_fiche_titre($langs->trans("SetStock"));
print "<form action=\"product.php?id=$product->id\" method=\"post\">\n"; print "<form action=\"product.php?id=$object->id\" method=\"post\">\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="create_stock">'; print '<input type="hidden" name="action" value="create_stock">';
print '<table class="border" width="100%"><tr>'; print '<table class="border" width="100%"><tr>';
@ -645,19 +622,19 @@ else
/* ************************************************************************** */ /* ************************************************************************** */
if (empty($action) && $product->id) if (empty($action) && $object->id)
{ {
print "<div class=\"tabsAction\">\n"; print "<div class=\"tabsAction\">\n";
if ($user->rights->stock->mouvement->creer) if ($user->rights->stock->mouvement->creer)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&amp;action=correction">'.$langs->trans("StockCorrection").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=correction">'.$langs->trans("StockCorrection").'</a>';
} }
//if (($user->rights->stock->mouvement->creer) && ! $product->hasbatch()) //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch())
if ($user->rights->stock->mouvement->creer) if ($user->rights->stock->mouvement->creer)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&amp;action=transfert">'.$langs->trans("StockMovement").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=transfert">'.$langs->trans("StockMovement").'</a>';
} }
print '</div>'; print '</div>';
@ -678,7 +655,7 @@ print '<td align="right">'.$langs->trans("EstimatedStockValueShort").'</td>';
print '<td align="right">'.$langs->trans("SellPriceMin").'</td>'; print '<td align="right">'.$langs->trans("SellPriceMin").'</td>';
print '<td align="right">'.$langs->trans("EstimatedStockValueSellShort").'</td>'; print '<td align="right">'.$langs->trans("EstimatedStockValueSellShort").'</td>';
print '</tr>'; print '</tr>';
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
{ {
print '<tr class="liste_titre"><td width="10%"></td>'; print '<tr class="liste_titre"><td width="10%"></td>';
print '<td align="right" width="10%">'.$langs->trans("batch_number").'</td>'; print '<td align="right" width="10%">'.$langs->trans("batch_number").'</td>';
@ -695,7 +672,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product";
$sql.= " WHERE ps.reel != 0"; $sql.= " WHERE ps.reel != 0";
$sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND ps.fk_entrepot = e.rowid";
$sql.= " AND e.entity IN (".getEntity('stock', 1).")"; $sql.= " AND e.entity IN (".getEntity('stock', 1).")";
$sql.= " AND ps.fk_product = ".$product->id; $sql.= " AND ps.fk_product = ".$object->id;
$sql.= " ORDER BY e.label"; $sql.= " ORDER BY e.label";
$entrepotstatic=new Entrepot($db); $entrepotstatic=new Entrepot($db);
@ -718,25 +695,25 @@ if ($resql)
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>'; print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>'; print '<td align="right">'.$obj->reel.($obj->reel<0?' '.img_warning():'').'</td>';
// PMP // PMP
print '<td align="right">'.(price2num($product->pmp)?price2num($product->pmp,'MU'):'').'</td>'; print '<td align="right">'.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').'</td>';
// Value purchase // Value purchase
print '<td align="right">'.(price2num($product->pmp)?price(price2num($product->pmp*$obj->reel,'MT')):'').'</td>'; print '<td align="right">'.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').'</td>';
// Sell price // Sell price
print '<td align="right">'; print '<td align="right">';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price,'MU'),1); if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price,'MU'),1);
else print $langs->trans("Variable"); else print $langs->trans("Variable");
print '</td>'; print '</td>';
// Value sell // Value sell
print '<td align="right">'; print '<td align="right">';
if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price*$obj->reel,'MT'),1).'</td>'; if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).'</td>';
else print $langs->trans("Variable"); else print $langs->trans("Variable");
print '</tr>'; ; print '</tr>'; ;
$total += $obj->reel; $total += $obj->reel;
if (price2num($product->pmp)) $totalwithpmp += $obj->reel; if (price2num($object->pmp)) $totalwithpmp += $obj->reel;
$totalvalue = $totalvalue + ($product->pmp*$obj->reel); $totalvalue = $totalvalue + ($object->pmp*$obj->reel);
$totalvaluesell = $totalvaluesell + ($product->price*$obj->reel); $totalvaluesell = $totalvaluesell + ($object->price*$obj->reel);
//Batch Detail //Batch Detail
if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) if ((! empty($conf->productbatch->enabled)) && $object->hasbatch())
{ {
$details=Productbatch::findAll($db,$obj->product_stock_id); $details=Productbatch::findAll($db,$obj->product_stock_id);
if ($details<0) dol_print_error($db); if ($details<0) dol_print_error($db);
@ -762,7 +739,7 @@ if ($resql)
{ {
print "\n".'<tr><td align="right">'; print "\n".'<tr><td align="right">';
print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' '; print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&amp;action=transfert&amp;pdluoid='.$pdluo->id.'">'.$langs->trans("StockMovement").'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=transfert&amp;pdluoid='.$pdluo->id.'">'.$langs->trans("StockMovement").'</a>';
// Disabled, because edition of stock content must use the "Correct stock menu". // Disabled, because edition of stock content must use the "Correct stock menu".
// Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ...
//print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&amp;action=editline&amp;lineid='.$pdluo->id.'#'.$pdluo->id.'">'; //print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$id.'&amp;action=editline&amp;lineid='.$pdluo->id.'#'.$pdluo->id.'">';

View File

@ -21,7 +21,9 @@
<!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP --> <!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP -->
<?php <?php
$langs->load("productbatch"); if (! is_object($product)) $product=$object;
$langs->load("productbatch");
if (empty($id)) $id = $object->id; if (empty($id)) $id = $object->id;

View File

@ -21,7 +21,11 @@
<!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP --> <!-- BEGIN PHP TEMPLATE STOCKCORRECTION.TPL.PHP -->
<?php <?php
$pdluoid=GETPOST('pdluoid','int'); if (! is_object($product)) $product=$object;
$langs->load("productbatch");
$pdluoid=GETPOST('pdluoid','int');
$pdluo = new Productbatch($db); $pdluo = new Productbatch($db);

View File

@ -58,9 +58,9 @@ if ($cancel == $langs->trans("Cancel"))
if ($action == 'delete' && GETPOST('langtodelete','alpha')) if ($action == 'delete' && GETPOST('langtodelete','alpha'))
{ {
$product = new Product($db); $object = new Product($db);
$product->fetch($id); $object->fetch($id);
$product->delMultiLangs(GETPOST('langtodelete','alpha')); $object->delMultiLangs(GETPOST('langtodelete','alpha'));
} }
// Add translation // Add translation
@ -68,33 +68,33 @@ if ($action == 'vadd' &&
$cancel != $langs->trans("Cancel") && $cancel != $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer)) ($user->rights->produit->creer || $user->rights->service->creer))
{ {
$product = new Product($db); $object = new Product($db);
$product->fetch($id); $object->fetch($id);
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
// update de l'objet // update de l'objet
if ( $_POST["forcelangprod"] == $current_lang ) if ( $_POST["forcelangprod"] == $current_lang )
{ {
$product->label = $_POST["libelle"]; $object->label = $_POST["libelle"];
$product->description = dol_htmlcleanlastbr($_POST["desc"]); $object->description = dol_htmlcleanlastbr($_POST["desc"]);
$product->note = dol_htmlcleanlastbr($_POST["note"]); $object->note = dol_htmlcleanlastbr($_POST["note"]);
} }
else else
{ {
$product->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"];
$product->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]);
$product->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]); $object->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]);
} }
// sauvegarde en base // sauvegarde en base
if ( $product->setMultiLangs() > 0 ) if ( $object->setMultiLangs() > 0 )
{ {
$action = ''; $action = '';
} }
else else
{ {
$action = 'add'; $action = 'add';
setEventMessage($product->error,'errors'); setEventMessage($object->error,'errors');
} }
} }
@ -103,34 +103,34 @@ if ($action == 'vedit' &&
$cancel != $langs->trans("Cancel") && $cancel != $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer)) ($user->rights->produit->creer || $user->rights->service->creer))
{ {
$product = new Product($db); $object = new Product($db);
$product->fetch($id); $object->fetch($id);
$current_lang = $langs->getDefaultLang(); $current_lang = $langs->getDefaultLang();
foreach ( $product->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet foreach ( $object->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet
{ {
if ( $key == $current_lang ) if ( $key == $current_lang )
{ {
$product->label = $_POST["libelle-".$key]; $object->label = $_POST["libelle-".$key];
$product->description = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]);
$product->note = dol_htmlcleanlastbr($_POST["note-".$key]); $object->note = dol_htmlcleanlastbr($_POST["note-".$key]);
} }
else else
{ {
$product->multilangs[$key]["label"] = $_POST["libelle-".$key]; $object->multilangs[$key]["label"] = $_POST["libelle-".$key];
$product->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]);
$product->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]); $object->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]);
} }
} }
if ( $product->setMultiLangs() > 0 ) if ( $object->setMultiLangs() > 0 )
{ {
$action = ''; $action = '';
} }
else else
{ {
$action = 'edit'; $action = 'edit';
setEventMessage($product->error,'errors'); setEventMessage($object->error,'errors');
} }
} }
@ -139,24 +139,24 @@ if ($action == 'vdelete' &&
$cancel != $langs->trans("Cancel") && $cancel != $langs->trans("Cancel") &&
($user->rights->produit->creer || $user->rights->service->creer)) ($user->rights->produit->creer || $user->rights->service->creer))
{ {
$product = new Product($db); $object = new Product($db);
$product->fetch($id); $object->fetch($id);
$langtodelete=GETPOST('langdel','alpha'); $langtodelete=GETPOST('langdel','alpha');
if ( $product->delMultiLangs($langtodelete) > 0 ) if ( $object->delMultiLangs($langtodelete) > 0 )
{ {
$action = ''; $action = '';
} }
else else
{ {
$action = 'edit'; $action = 'edit';
setEventMessage($product->error,'errors'); setEventMessage($object->error,'errors');
} }
} }
$product = new Product($db); $object = new Product($db);
$result = $product->fetch($id,$ref); $result = $object->fetch($id,$ref);
/* /*
@ -168,20 +168,10 @@ llxHeader("","",$langs->trans("Translation"));
$form = new Form($db); $form = new Form($db);
$formadmin=new FormAdmin($db); $formadmin=new FormAdmin($db);
$head=product_prepare_head($product); $head=product_prepare_head($object);
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$object->type);
$picto=($product->type==Product::TYPE_SERVICE?'service':'product'); $picto=($object->type==Product::TYPE_SERVICE?'service':'product');
dol_fiche_head($head, 'translation', $titre, 0, $picto);
print '<table class="border" width="100%">';
// Reference
print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
print $form->showrefnav($product,'ref','',1,'ref');
print '</td>';
print '</tr>';
print '</table>';
if ($action == 'edit') if ($action == 'edit')
{ {
@ -191,33 +181,40 @@ if ($action == 'edit')
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="vedit">'; print '<input type="hidden" name="action" value="vedit">';
print '<input type="hidden" name="id" value="'.$product->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
if (! empty($product->multilangs)) dol_fiche_head($head, 'translation', $titre, 0, $picto);
dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
if (! empty($object->multilangs))
{ {
foreach ($product->multilangs as $key => $value) foreach ($object->multilangs as $key => $value)
{ {
print "<br><b><u>".$langs->trans('Language_'.$key)." :</u></b><br>"; $s=picto_from_langcode($key);
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$product->multilangs[$key]["label"].'"></td></tr>'; print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle-'.$key.'" size="40" value="'.$object->multilangs[$key]["label"].'"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';
$doleditor = new DolEditor("desc-$key", $product->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80);
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Note').'</td><td>';
$doleditor = new DolEditor("note-$key", $product->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor = new DolEditor("note-$key", $object->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80);
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
print '<tr height="30px"><td colspan="2" align="right"><a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=vdelete&id='.$product->id.'&langdel='.$key.'">'.$langs->trans("Delete").'</a></td></tr>';
print '</table>'; print '</table>';
} }
} }
print '<br><div class="center">'; dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
@ -228,25 +225,30 @@ if ($action == 'edit')
} }
else else
{ {
$cnt_trans = 0; dol_fiche_head($head, 'translation', $titre, 0, $picto);
if (! empty($product->multilangs))
dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref');
$cnt_trans = 0;
if (! empty($object->multilangs))
{ {
foreach ($product->multilangs as $key => $value) foreach ($object->multilangs as $key => $value)
{ {
$cnt_trans++; $cnt_trans++;
$s=picto_from_langcode($key); $s=picto_from_langcode($key);
print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>"; print "<br>".($s?$s.' ':'')." <b>".$langs->trans('Language_'.$key).":</b> ".'<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&langtodelete='.$key.'">'.img_delete('', '')."</a><br>";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$product->multilangs[$key]["label"].'</td></tr>'; print '<tr><td width="15%">'.$langs->trans('Label').'</td><td>'.$object->multilangs[$key]["label"].'</td></tr>';
print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$product->multilangs[$key]["description"].'</td></tr>'; print '<tr><td width="15%">'.$langs->trans('Description').'</td><td>'.$object->multilangs[$key]["description"].'</td></tr>';
print '<tr><td width="15%">'.$langs->trans('Note').'</td><td>'.$product->multilangs[$key]["note"].'</td></tr>'; print '<tr><td width="15%">'.$langs->trans('Note').'</td><td>'.$object->multilangs[$key]["note"].'</td></tr>';
print '</table>'; print '</table>';
} }
} }
if (! $cnt_trans) print '<br>'. $langs->trans('NoTranslation'); if (! $cnt_trans) print '<br>'. $langs->trans('NoTranslation');
dol_fiche_end();
} }
print "</div>\n";
/* ************************************************************************** */ /* ************************************************************************** */
@ -260,8 +262,8 @@ print "\n<div class=\"tabsAction\">\n";
if ($action == '') if ($action == '')
if ($user->rights->produit->creer || $user->rights->service->creer) if ($user->rights->produit->creer || $user->rights->service->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=add&id='.$product->id.'">'.$langs->trans("Add").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=add&id='.$object->id.'">'.$langs->trans("Add").'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=edit&id='.$product->id.'">'.$langs->trans("Update").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/product/traduction.php?action=edit&id='.$object->id.'">'.$langs->trans("Update").'</a>';
} }
print "\n</div>\n"; print "\n</div>\n";
@ -284,7 +286,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Language').'</td><td>'; print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Language').'</td><td>';
print $formadmin->select_language('','forcelangprod',0,$product->multilangs,1); print $formadmin->select_language('','forcelangprod',0,$object->multilangs,1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>'; print '<tr><td valign="top" width="15%" class="fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>'; print '<tr><td valign="top" width="15%">'.$langs->trans('Description').'</td><td>';