From e8e6ba4140bc90c4bb949841e1ca3460e6d1f046 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Sat, 2 Dec 2006 15:29:11 +0000 Subject: [PATCH] Nettoyage inclusion de smarty --- htdocs/product/fiche.php | 966 ++++++++++++++++++++++----------------- 1 file changed, 555 insertions(+), 411 deletions(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index df928630cf4..ef9f66aeffd 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -24,10 +24,10 @@ */ /** - \file htdocs/product/fiche.php - \ingroup product - \brief Page de la fiche produit - \version $Revision$ + \file htdocs/product/fiche.php + \ingroup product + \brief Page de la fiche produit + \version $Revision$ */ require("./pre.inc.php"); @@ -40,7 +40,6 @@ require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); $langs->load("bills"); $langs->load("products"); - $mesg = ''; if (!$user->rights->produit->lire) accessforbidden(); @@ -48,7 +47,6 @@ if (!$user->rights->produit->lire) accessforbidden(); $types[0] = $langs->trans("Product"); $types[1] = $langs->trans("Service"); - /* * */ @@ -67,44 +65,62 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer) { $product = new Product($db); - $product->ref = $_POST["ref"]; - $product->libelle = $_POST["libelle"]; - $product->price = $_POST["price"]; - $product->tva_tx = $_POST["tva_tx"]; - $product->type = $_POST["type"]; - $product->status = $_POST["statut"]; - $product->description = $_POST["desc"]; - $product->note = $_POST["note"]; - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; + $product->ref = $_POST["ref"]; + $product->libelle = $_POST["libelle"]; + $product->price = $_POST["price"]; + $product->tva_tx = $_POST["tva_tx"]; + $product->type = $_POST["type"]; + $product->status = $_POST["statut"]; + $product->description = $_POST["desc"]; + $product->note = $_POST["note"]; + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; - // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - if($_POST["price_".$i]) - $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]); - else - $product->multiprices["$i"] = ""; - } - } - - if ( $value != $current_lang ) $e_product = $product; - + $product->canvas = $_POST["canvas"]; + // MultiPrix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) + { + if($_POST["price_".$i]) + $product->multiprices["$i"]=ereg_replace(" ","",$_POST["price_".$i]); + else + $product->multiprices["$i"] = ""; + } + } + + if ( $value != $current_lang ) $e_product = $product; + $id = $product->create($user); + // Produit spécifique if ($id > 0) - { + { + if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') ) + { + $class = 'Product'.ucfirst($product->canvas); + include_once('canvas/product.'.$product->canvas.'.class.php'); + + $product = new $class($db); + if ($product->CreateCanvas($id) > 0) + { + // Erreur + $id = 0; + } + } + } + + if ($id > 0) + { Header("Location: fiche.php?id=$id"); exit; - } + } else - { + { $mesg='
'.$product->error.'
'; $_GET["action"] = "create"; $_GET["type"] = $_POST["type"]; - } + } } // Action mise a jour d'un produit ou service @@ -112,33 +128,34 @@ if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel") && $user->rights->produit->creer) { - $product = new Product($db); - if ($product->fetch($_POST["id"])) + $product = new Product($db); + if ($product->fetch($_POST["id"])) { - $product->ref = $_POST["ref"]; - $product->libelle = $_POST["libelle"]; - if ( isset( $_POST["price"] ) ) + $product->ref = $_POST["ref"]; + $product->libelle = $_POST["libelle"]; + if ( isset( $_POST["price"] ) ) $product->price = $_POST["price"]; - $product->tva_tx = $_POST["tva_tx"]; - $product->description = $_POST["desc"]; - $product->note = $_POST["note"]; - $product->status = $_POST["statut"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; - - if ($product->check()) + $product->tva_tx = $_POST["tva_tx"]; + $product->description = $_POST["desc"]; + $product->note = $_POST["note"]; + $product->status = $_POST["statut"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; + $product->canvas = $_POST["canvas"]; + + if ($product->check()) { - if ($product->update($product->id, $user) > 0) + if ($product->update($product->id, $user) > 0) { - $_GET["action"] = ''; - $_GET["id"] = $_POST["id"]; + $_GET["action"] = ''; + $_GET["id"] = $_POST["id"]; } - else + else { - $_GET["action"] = 'edit'; - $_GET["id"] = $_POST["id"]; - $mesg = $product->error; + $_GET["action"] = 'edit'; + $_GET["id"] = $_POST["id"]; + $mesg = $product->error; } } else @@ -147,6 +164,20 @@ if ($_POST["action"] == 'update' && $_GET["id"] = $_POST["id"]; $mesg = $langs->trans("ErrorProductBadRefOrLabel"); } + + + // Produit spécifique + if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') ) + { + $class = 'Product'.ucfirst($product->canvas); + include_once('canvas/product.'.$product->canvas.'.class.php'); + + $product = new $class($db); + if ($product->FetchCanvas($_POST["id"])) + { + $product->UpdateCanvas($_POST); + } + } } } @@ -205,22 +236,22 @@ if ($_GET["action"] == 'clone' && $user->rights->produit->creer) */ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->produit->supprimer) { - $product = new Product($db); - $product->fetch($_GET["id"]); - $result = $product->delete($_GET["id"]); - - if ($result == 0) - { - llxHeader(); - print '
'.$langs->trans("ProductDeleted",$product->ref).'
'; - llxFooter(); - exit ; - } - else - { - $reload = 0; - $_GET["action"]=''; - } + $product = new Product($db); + $product->fetch($_GET["id"]); + $result = $product->delete($_GET["id"]); + + if ($result == 0) + { + llxHeader(); + print '
'.$langs->trans("ProductDeleted",$product->ref).'
'; + llxFooter(); + exit ; + } + else + { + $reload = 0; + $_GET["action"]=''; + } } @@ -231,36 +262,36 @@ if ($_POST["action"] == 'addinpropal') { $propal = New Propal($db); $result=$propal->fetch($_POST["propalid"]); - if ($result <= 0) - { - dolibarr_print_error($db,$propal->error); - exit; - } - + if ($result <= 0) + { + dolibarr_print_error($db,$propal->error); + exit; + } + $soc = new Societe($db); $soc->fetch($propal->socid,$user); $prod = new Product($db, $_GET['id']); $result=$prod->fetch($_GET['id']); - if ($result <= 0) - { - dolibarr_print_error($db,$prod->error); - exit; - } - + if ($result <= 0) + { + dolibarr_print_error($db,$prod->error); + exit; + } + // multiprix if ($conf->global->PRODUIT_MULTIPRICES == 1) - { - $pu = $prod->multiprices[$soc->price_level]; - } + { + $pu = $prod->multiprices[$soc->price_level]; + } else - { + { $pu=$prod->price; - } - - $desc = $prod->description; + } + + $desc = $prod->description; $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); - + $result = $propal->addline($propal->id, $desc, $pu, @@ -269,11 +300,11 @@ if ($_POST["action"] == 'addinpropal') $prod->id, $_POST["remise_percent"]); if ($result > 0) - { - Header("Location: ../comm/propal.php?propalid=".$propal->id); - return; - } - + { + Header("Location: ../comm/propal.php?propalid=".$propal->id); + return; + } + $mesg = $langs->trans("ErrorUnknown").": $result"; } @@ -282,37 +313,37 @@ if ($_POST["action"] == 'addinpropal') */ if ($_POST["action"] == 'addincommande') { - $product = new Product($db); - $result = $product->fetch($_GET["id"]); - - $commande = New Commande($db); - $commande->fetch($_POST["commandeid"]); - - $soc = new Societe($db); - $soc->fetch($commande->socid,$user); - - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES == 1) + $product = new Product($db); + $result = $product->fetch($_GET["id"]); + + $commande = New Commande($db); + $commande->fetch($_POST["commandeid"]); + + $soc = new Societe($db); + $soc->fetch($commande->socid,$user); + + // multiprix + if ($conf->global->PRODUIT_MULTIPRICES == 1) { - $pu = $product->multiprices[$soc->price_level]; + $pu = $product->multiprices[$soc->price_level]; } - else + else { - $pu=$product->price; + $pu=$product->price; } - - $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx); - - $result = $commande->addline($commande->id, - $product->description, - $pu, - $_POST["qty"], - $tva_tx, - $product->id, - $_POST["remise_percent"]); - - Header("Location: ../commande/fiche.php?id=".$commande->id); - exit; + + $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx); + + $result = $commande->addline($commande->id, + $product->description, + $pu, + $_POST["qty"], + $tva_tx, + $product->id, + $_POST["remise_percent"]); + + Header("Location: ../commande/fiche.php?id=".$commande->id); + exit; } /* @@ -320,340 +351,447 @@ if ($_POST["action"] == 'addincommande') */ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer) { - $product = new Product($db); - $result = $product->fetch($_GET["id"]); - - $facture = New Facture($db); - $facture->fetch($_POST["factureid"]); - - $soc = new Societe($db); - $soc->fetch($facture->socid,$user); - - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES == 1) + $product = new Product($db); + $result = $product->fetch($_GET["id"]); + + $facture = New Facture($db); + $facture->fetch($_POST["factureid"]); + + $soc = new Societe($db); + $soc->fetch($facture->socid,$user); + + // multiprix + if ($conf->global->PRODUIT_MULTIPRICES == 1) { - $pu = $product->multiprices[$soc->price_level]; + $pu = $product->multiprices[$soc->price_level]; } - else + else { - $pu=$product->price; + $pu=$product->price; } - - $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx); - - $facture->addline($facture->id, - $product->description, - $pu, - $_POST["qty"], - $tva_tx, - $product->id, - $_POST["remise_percent"]); - - Header("Location: ../compta/facture.php?facid=".$facture->id); - exit; + + $tva_tx = get_default_tva($mysoc,$soc,$product->tva_tx); + + $facture->addline($facture->id, + $product->description, + $pu, + $_POST["qty"], + $tva_tx, + $product->id, + $_POST["remise_percent"]); + + Header("Location: ../compta/facture.php?facid=".$facture->id); + exit; } if ($_POST["cancel"] == $langs->trans("Cancel")) { - $action = ''; - Header("Location: fiche.php?id=".$_POST["id"]); - exit; + $action = ''; + Header("Location: fiche.php?id=".$_POST["id"]); + exit; } - $html = new Form($db); - /* * Action création du produit */ if ($_GET["action"] == 'create' && $user->rights->produit->creer) { - $product = new Product($db); - - if ($_error == 1) + $product = new Product($db); + + if ($_error == 1) { - $product = $e_product; + $product = $e_product; } + + llxHeader("","",$langs->trans("CardProduct".$product->type)); - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - if ($mesg) print "$mesg\n"; - - print '
'; - print ''; - print ''."\n"; - - if ($_GET["type"]==0) { $title=$langs->trans("NewProduct"); } - if ($_GET["type"]==1) { $title=$langs->trans("NewService"); } - print_fiche_titre($title); - - print ''; - print ''; - print ''; - print ''; - - if($conf->global->PRODUIT_MULTIPRICES == 1) + print ''; + print ''; + print ''."\n"; + + if ($_GET["type"]==0) { $title=$langs->trans("NewProduct"); } + if ($_GET["type"]==1) { $title=$langs->trans("NewService"); } + print_fiche_titre($title); + + print '
'.$langs->trans("Ref").''; - if ($_error == 1) + if ($mesg) print "$mesg\n"; + + if ($_GET["canvas"] == '') { - print $langs->trans("RefAlreadyExists"); - } - print '
'.$langs->trans("Label").'
'; + print ''; + print ''; - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - print ''; - } + print $langs->trans("RefAlreadyExists"); } - // PRIX - else + print ''; + print ''; + + if($conf->global->PRODUIT_MULTIPRICES == 1) { - print ''; + print ''; + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) + { + print ''; + } + } + // PRIX + else + { + print ''; + } + + print ''; + + print ''; + + if ($_GET["type"] == 0 && $conf->stock->enabled) + { + print ''; + } + else + { + print ''; + } + + // Description (utilisé dans facture, propale...) + print '"; + + if ($_GET["type"] == 1) + { + print ''; + } + + // Note (invisible sur facture, propales...) + print '"; + + print ''; + print '
'.$langs->trans("Ref").''; + if ($_error == 1) { - print '
'.$langs->trans("SellingPrice").' 1
'.$langs->trans("SellingPrice").' '.$i.'
'.$langs->trans("Label").'
'.$langs->trans("SellingPrice").'
'.$langs->trans("SellingPrice").' 1
'.$langs->trans("SellingPrice").' '.$i.'
'.$langs->trans("SellingPrice").'
'.$langs->trans("VATRate").''; + print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); + print '
'.$langs->trans("Status").''; + print ''; + print '
Seuil stock'; + print ''; + print '
'.$langs->trans("Description").''; + + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + + print "
'.$langs->trans("Duration").'  '; + print ''.$langs->trans("Day").' '; + print ''.$langs->trans("Week").' '; + print ''.$langs->trans("Month").' '; + print ''.$langs->trans("Year").' '; + print '
'.$langs->trans("NoteNotVisibleOnBill").''; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note','',200,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + print "
'; + print '
'; } - - print ''.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); - print ''; - - print ''.$langs->trans("Status").''; - print ''; - print ''; - - if ($_GET["type"] == 0 && $conf->stock->enabled) + else { - print 'Seuil stock'; - print ''; - print ''; + //RODO + $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/'; + $smarty->display('fiche-create.tpl'); } - else - { - print ''; - } - - // Description (utilisé dans facture, propale...) - print ''.$langs->trans("Description").''; - - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print ''; - } - - print ""; - - if ($_GET["type"] == 1) - { - print ''.$langs->trans("Duration").'  '; - print ''.$langs->trans("Day").' '; - print ''.$langs->trans("Week").' '; - print ''.$langs->trans("Month").' '; - print ''.$langs->trans("Year").' '; - print ''; - } - - // Note (invisible sur facture, propales...) - print ''.$langs->trans("NoteNotVisibleOnBill").''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note','',200,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print ''; - } - print ""; - - print ''; - print ''; - print ''; } - /** * Fiche produit */ if ($_GET["id"] || $_GET["ref"]) { - $product = new Product($db); + $product = new Product($db); - if ($_GET["ref"]) + if ($_GET["ref"]) { - $result = $product->fetch('',$_GET["ref"]); - $_GET["id"] = $product->id; + $result = $product->fetch('',$_GET["ref"]); + $_GET["id"] = $product->id; } - elseif ($_GET["id"]) + elseif ($_GET["id"]) { - $result = $product->fetch($_GET["id"]); + $result = $product->fetch($_GET["id"]); } - - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - if ( $result ) + + // Gestion des produits specifiques + if ($product->canvas <> '' && file_exists('canvas/product.'.$product->canvas.'.class.php') ) { + $class = 'Product'.ucfirst($product->canvas); + include_once('canvas/product.'.$product->canvas.'.class.php'); - if ($_GET["action"] <> 'edit') + $product = new $class($db); + + $result = $product->FetchCanvas($_GET["id"]); + + $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$product->canvas.'/'; + + + $product->assign_values($smarty); + } + // END TODO RODO FINISH THIS PART + + llxHeader("","",$langs->trans("CardProduct".$product->type)); + + if ( $result ) + { + if ($_GET["action"] <> 'edit' && $product->canvas <> '') { - /* - * En mode visu - */ - - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - dolibarr_fiche_head($head, 'card', $titre); - - // Confirmation de la suppression de la facture - if ($_GET["action"] == 'delete') + /* + * Smarty en mode visu + */ + + $head=product_prepare_head($product); + $titre=$langs->trans("CardProduct".$product->type); + dolibarr_fiche_head($head, 'card', $titre); + print "\n\n"; + // Confirmation de la suppression de la facture + if ($_GET["action"] == 'delete') { - $html = new Form($db); - $html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete"); - print "
\n"; + $html = new Form($db); + $html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete"); + print "
\n"; } + print($mesg); - print($mesg); - - print ''; - - print ""; - - $nblignes=6; - if ($product->type == 0 && $conf->stock->enabled) $nblignes++; - if ($product->type == 1) $nblignes++; - - // Reference - print ''; - - if ($product->is_photo_available($conf->produit->dir_output)) + print '
'.$langs->trans("Ref").''; - $product->load_previous_next_ref(); - $previous_ref = $product->ref_previous?''.img_previous().'':''; - $next_ref = $product->ref_next?''.img_next().'':''; - if ($previous_ref || $next_ref) print '
'; - print ''.$product->ref.''; - if ($previous_ref || $next_ref) print ''.$previous_ref.''.$next_ref.'
'; - print '
'; + print ""; + + $nblignes=6; + if ($product->type == 0 && $conf->stock->enabled) $nblignes++; + if ($product->type == 1) $nblignes++; + + // Reference + print ''; + + if ($product->is_photo_available($conf->produit->dir_output)) { - // Photo - print ''; + // Photo + print ''; } - - print ''; - - // Libelle - print ''; - print ''; - - // MultiPrix - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - print ''; - print ''; - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - print ''; - print ''; - } - } - // Prix - else - { - print ''; - print ''; - } - - // Statut - print ''; - - // TVA - - print ''; - - // Stock - if ($product->type == 0 && $conf->stock->enabled) + + print ''; + + $smarty->display('fiche-view.tpl'); + + // Statut + print ''; + + // TVA + + print ''; + + // Description + print ''; + + // Durée + if ($product->type == 1) { - print ''; - if ($product->no_stock) + print ''; + } + + // Note + print ''; + print "
'.$langs->trans("Ref").''; + $product->load_previous_next_ref(); + $previous_ref = $product->ref_previous?''.img_previous().'':''; + $next_ref = $product->ref_next?''.img_next().'':''; + if ($previous_ref || $next_ref) print '
'; + print ''.$product->ref.''; + if ($previous_ref || $next_ref) print ''.$previous_ref.''.$next_ref.'
'; + print '
'; - $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); - print ''; + $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); + print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").' 1'.price($product->price).'
'.$langs->trans("SellingPrice").' '.$i.''.price($product->multiprices["$i"]).'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; - print $product->getLibStatut(2); - print '
'.$langs->trans("VATRate").''.$product->tva_tx.'%
'.$langs->trans("Status").''; + print $product->getLibStatut(2); + print '
'.$langs->trans("VATRate").''.$product->tva_tx.'%
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Stock").'
'.$langs->trans("Duration").''.$product->duration_value.' '; + + if ($product->duration_value > 1) { - print "Pas de définition de stock pour ce produit"; + $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); } - else + else { + $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $langs->trans($dur[$product->duration_unit])." "; + + print '
'.$langs->trans("Note").''.nl2br($product->note).'
\n"; + print "\n\n"; + } + + + if ($_GET["action"] <> 'edit' && $product->canvas == '') + { + /* + * En mode visu + */ + + $head=product_prepare_head($product); + $titre=$langs->trans("CardProduct".$product->type); + dolibarr_fiche_head($head, 'card', $titre); + print "\n\n"; + // Confirmation de la suppression de la facture + if ($_GET["action"] == 'delete') + { + $html = new Form($db); + $html->form_confirm("fiche.php?id=".$product->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete"); + print "
\n"; + } + + print($mesg); + + print ''; + print ""; + + $nblignes=6; + if ($product->type == 0 && $conf->stock->enabled) $nblignes++; + if ($product->type == 1) $nblignes++; + + // Reference + print ''; + + if ($product->is_photo_available($conf->produit->dir_output)) + { + // Photo + print ''; + } + + print ''; + + // Libelle + print ''; + print ''; + + // MultiPrix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + print ''; + print ''; + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) + { + print ''; + print ''; + } + } + // Prix + else + { + print ''; + print ''; + } + + // Statut + print ''; + + // TVA + + print ''; + + // Stock + if ($product->type == 0 && $conf->stock->enabled) + { + print ''; + if ($product->no_stock) { - if ($product->stock_reel <= $product->seuil_stock_alerte) + print "'; + print ''; } - + // Description - print ''; - - // Durée - if ($product->type == 1) + print ''; + + // Durée + if ($product->type == 1) { - print ''; + else { + $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); + } + print $langs->trans($dur[$product->duration_unit])." "; + + print ''; } - - // Note - print ''; - - print "
'.$langs->trans("Ref").''; + $product->load_previous_next_ref(); + $previous_ref = $product->ref_previous?''.img_previous().'':''; + $next_ref = $product->ref_next?''.img_next().'':''; + if ($previous_ref || $next_ref) print '
'; + print ''.$product->ref.''; + if ($previous_ref || $next_ref) print ''.$previous_ref.''.$next_ref.'
'; + print '
'; + $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); + print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").' 1'.price($product->price).'
'.$langs->trans("SellingPrice").' '.$i.''.price($product->multiprices["$i"]).'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; + print $product->getLibStatut(2); + print '
'.$langs->trans("VATRate").''.$product->tva_tx.'%
'.$langs->trans("Stock").'Pas de définition de stock pour ce produit"; + } + else + { + if ($product->stock_reel <= $product->seuil_stock_alerte) { - print ''.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; + print ''.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; } - else + else { - print "".$product->stock_reel; + print "".$product->stock_reel; } } - print '
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Description").''.nl2br($product->description).'
'.$langs->trans("Duration").''.$product->duration_value.' '; - - if ($product->duration_value > 1) + print '
'.$langs->trans("Duration").''.$product->duration_value.' '; + + if ($product->duration_value > 1) { - $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); + $dur=array("d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); } - else { - $dur=array("d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); - } - print $langs->trans($dur[$product->duration_unit])." "; - - print '
'.$langs->trans("Note").''.nl2br($product->note).'
\n"; - - print "\n"; + + // Note + print ''.$langs->trans("Note").''.nl2br($product->note).''; + + print "\n"; + + print "\n\n"; } } - + /* * Fiche en mode edition */ if ($_GET["action"] == 'edit' && $user->rights->produit->creer) - { - + { print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, ""); if ($mesg) { print '
'.$mesg.'

'; } - print "
\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - + if ( $product->canvas == '') + { + print "\n"; + print "\n"; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'; + print ''; + print ''; print ''; if ($product->type == 0 && $conf->stock->enabled) - { + { print "".''; - } + } else - { - print ''; + { + print ''; } - + // Description (utilisé dans facture, propale...) print '"; print "\n"; if ($product->type == 1) - { + { print '"; + { + print '"; + } + print ""; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("VATRate").''; print $html->select_tva("tva_tx", $product->tva_tx, $mysoc, '', $product->tva_tx); @@ -661,47 +799,47 @@ if ($_GET["id"] || $_GET["ref"]) print '
'.$langs->trans("Status").''; print '
Seuil stock'; print ''; print '
'.$langs->trans("Description").''; print "\n"; if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false); - $doleditor->Create(); + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc',$product->description,160,'dolibarr_notes','',false); + $doleditor->Create(); } else { - print '"; + print '"; } print "
'.$langs->trans("Duration").''; print '  '; print 'duration_unit=='d'?' checked':'').'>'.$langs->trans("Day"); @@ -717,25 +855,31 @@ if ($_GET["id"] || $_GET["ref"]) // Note print '
'.$langs->trans("NoteNotVisibleOnBill").''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false); - $doleditor->Create(); - } + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note',$product->note,200,'dolibarr_notes','',false); + $doleditor->Create(); + } else - { - print '"; - } - print "
 '; print '
'; print '
'; - } + print "\n"; + } + else + { + $smarty->display('fiche-edit.tpl'); + } + } }