Nettoyage inclusion de smarty
This commit is contained in:
parent
67fb127024
commit
e8e6ba4140
@ -40,7 +40,6 @@ require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
|||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
|
|
||||||
|
|
||||||
$mesg = '';
|
$mesg = '';
|
||||||
|
|
||||||
if (!$user->rights->produit->lire) accessforbidden();
|
if (!$user->rights->produit->lire) accessforbidden();
|
||||||
@ -48,7 +47,6 @@ if (!$user->rights->produit->lire) accessforbidden();
|
|||||||
$types[0] = $langs->trans("Product");
|
$types[0] = $langs->trans("Product");
|
||||||
$types[1] = $langs->trans("Service");
|
$types[1] = $langs->trans("Service");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -78,6 +76,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
|||||||
$product->duration_value = $_POST["duration_value"];
|
$product->duration_value = $_POST["duration_value"];
|
||||||
$product->duration_unit = $_POST["duration_unit"];
|
$product->duration_unit = $_POST["duration_unit"];
|
||||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
||||||
|
$product->canvas = $_POST["canvas"];
|
||||||
// MultiPrix
|
// MultiPrix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
{
|
{
|
||||||
@ -94,6 +93,23 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
|||||||
|
|
||||||
$id = $product->create($user);
|
$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)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
Header("Location: fiche.php?id=$id");
|
Header("Location: fiche.php?id=$id");
|
||||||
@ -126,6 +142,7 @@ if ($_POST["action"] == 'update' &&
|
|||||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
||||||
$product->duration_value = $_POST["duration_value"];
|
$product->duration_value = $_POST["duration_value"];
|
||||||
$product->duration_unit = $_POST["duration_unit"];
|
$product->duration_unit = $_POST["duration_unit"];
|
||||||
|
$product->canvas = $_POST["canvas"];
|
||||||
|
|
||||||
if ($product->check())
|
if ($product->check())
|
||||||
{
|
{
|
||||||
@ -147,6 +164,20 @@ if ($_POST["action"] == 'update' &&
|
|||||||
$_GET["id"] = $_POST["id"];
|
$_GET["id"] = $_POST["id"];
|
||||||
$mesg = $langs->trans("ErrorProductBadRefOrLabel");
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,10 +391,8 @@ if ($_POST["cancel"] == $langs->trans("Cancel"))
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action création du produit
|
* Action création du produit
|
||||||
*/
|
*/
|
||||||
@ -380,6 +409,8 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
|||||||
|
|
||||||
if ($mesg) print "$mesg\n";
|
if ($mesg) print "$mesg\n";
|
||||||
|
|
||||||
|
if ($_GET["canvas"] == '')
|
||||||
|
{
|
||||||
print '<form action="fiche.php" method="post">';
|
print '<form action="fiche.php" method="post">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
|
print '<input type="hidden" name="type" value="'.$_GET["type"].'">'."\n";
|
||||||
@ -480,7 +511,13 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//RODO
|
||||||
|
$smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/';
|
||||||
|
$smarty->display('fiche-create.tpl');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fiche produit
|
* Fiche produit
|
||||||
@ -499,21 +536,37 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
$result = $product->fetch($_GET["id"]);
|
$result = $product->fetch($_GET["id"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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');
|
||||||
|
|
||||||
|
$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));
|
llxHeader("","",$langs->trans("CardProduct".$product->type));
|
||||||
|
|
||||||
if ( $result )
|
if ( $result )
|
||||||
{
|
{
|
||||||
|
if ($_GET["action"] <> 'edit' && $product->canvas <> '')
|
||||||
if ($_GET["action"] <> 'edit')
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* En mode visu
|
* Smarty en mode visu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$head=product_prepare_head($product);
|
$head=product_prepare_head($product);
|
||||||
$titre=$langs->trans("CardProduct".$product->type);
|
$titre=$langs->trans("CardProduct".$product->type);
|
||||||
dolibarr_fiche_head($head, 'card', $titre);
|
dolibarr_fiche_head($head, 'card', $titre);
|
||||||
|
print "\n<!-- CUT HERE -->\n";
|
||||||
// Confirmation de la suppression de la facture
|
// Confirmation de la suppression de la facture
|
||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
@ -522,11 +575,9 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print "<br />\n";
|
print "<br />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
print($mesg);
|
print($mesg);
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
print "<tr>";
|
print "<tr>";
|
||||||
|
|
||||||
$nblignes=6;
|
$nblignes=6;
|
||||||
@ -534,7 +585,92 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
if ($product->type == 1) $nblignes++;
|
if ($product->type == 1) $nblignes++;
|
||||||
|
|
||||||
// Reference
|
// Reference
|
||||||
print '<td width="15%">'.$langs->trans("Ref").'</td><td>';
|
print '<td width="15%">'.$langs->trans("Ref").'</td><td width="85%">';
|
||||||
|
$product->load_previous_next_ref();
|
||||||
|
$previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
|
||||||
|
$next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
|
||||||
|
if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
|
||||||
|
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
|
||||||
|
if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>';
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
if ($product->is_photo_available($conf->produit->dir_output))
|
||||||
|
{
|
||||||
|
// Photo
|
||||||
|
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
|
||||||
|
$nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$smarty->display('fiche-view.tpl');
|
||||||
|
|
||||||
|
// Statut
|
||||||
|
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||||
|
print $product->getLibStatut(2);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// TVA
|
||||||
|
|
||||||
|
print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.'%</td></tr>';
|
||||||
|
|
||||||
|
// Description
|
||||||
|
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
|
||||||
|
|
||||||
|
// Durée
|
||||||
|
if ($product->type == 1)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("Duration").'</td><td>'.$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"));
|
||||||
|
}
|
||||||
|
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 '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note
|
||||||
|
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'.nl2br($product->note).'</td></tr>';
|
||||||
|
print "</table>\n";
|
||||||
|
print "</div>\n<!-- CUT HERE -->\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<!-- CUT HERE -->\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 "<br />\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print($mesg);
|
||||||
|
|
||||||
|
print '<table class="border" width="100%">';
|
||||||
|
print "<tr>";
|
||||||
|
|
||||||
|
$nblignes=6;
|
||||||
|
if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
|
||||||
|
if ($product->type == 1) $nblignes++;
|
||||||
|
|
||||||
|
// Reference
|
||||||
|
print '<td width="15%">'.$langs->trans("Ref").'</td><td width="85%">';
|
||||||
$product->load_previous_next_ref();
|
$product->load_previous_next_ref();
|
||||||
$previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
|
$previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
|
||||||
$next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
|
$next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
|
||||||
@ -631,7 +767,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n<!-- CUT HERE -->\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,21 +776,23 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'edit' && $user->rights->produit->creer)
|
if ($_GET["action"] == 'edit' && $user->rights->produit->creer)
|
||||||
{
|
{
|
||||||
|
|
||||||
print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, "");
|
print_fiche_titre($langs->trans('Edit').' '.$types[$product->type].' : '.$product->ref, "");
|
||||||
|
|
||||||
if ($mesg) {
|
if ($mesg) {
|
||||||
print '<br><div class="error">'.$mesg.'</div><br>';
|
print '<br><div class="error">'.$mesg.'</div><br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $product->canvas == '')
|
||||||
|
{
|
||||||
|
print "<!-- CUT HERE -->\n";
|
||||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||||
|
print '<input type="hidden" name="canvas" value="'.$product->canvas.'">';
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
|
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="20" value="'.$product->ref.'"></td></tr>';
|
||||||
print '<td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
print '<td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||||||
|
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">';
|
print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">';
|
||||||
print $html->select_tva("tva_tx", $product->tva_tx, $mysoc, '', $product->tva_tx);
|
print $html->select_tva("tva_tx", $product->tva_tx, $mysoc, '', $product->tva_tx);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -735,6 +873,12 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
print "<!-- CUT HERE -->\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$smarty->display('fiche-edit.tpl');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user