Fix: Pb creation répertoire.

This commit is contained in:
Laurent Destailleur 2005-06-28 21:49:05 +00:00
parent 71df91f4e0
commit 6e420ec7d2

View File

@ -59,127 +59,123 @@ $mesg = '';
if ($_GET["id"]) if ($_GET["id"])
{ {
$product = new Product($db); $product = new Product($db);
$result = $product->fetch($_GET["id"]); $result = $product->fetch($_GET["id"]);
if ($result) if ($result)
{ {
// Efface rep obsolete // Efface rep obsolete
if(is_dir(DOL_DOCUMENT_ROOT."/document/produits")) if(is_dir(DOL_DOCUMENT_ROOT."/document/produits"))
rmdir(DOL_DOCUMENT_ROOT."/document/produits"); rmdir(DOL_DOCUMENT_ROOT."/document/produits");
// Création répertoire pour images générées // Création répertoire pour images générées
// $conf->produit->dir_images définit dans master.inc.php // $conf->produit->dir_images définit dans master.inc.php
$dir = $conf->produit->dir_images."/".$product->id; $dir = $conf->produit->dir_images."/".$product->id;
if (! file_exists($dir)) if (! file_exists($dir))
{
umask(0);
if(!file_exists($conf->produit->dir_images)) {
mkdir($conf->produit->dir_images);
}
if (! mkdir($dir, 0755))
{
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
}
}
$img_propal_name = "propal12mois.png";
$filenbpropal = $dir . "/" . $img_propal_name;
$filenbvente = $dir . "/vente12mois.png";
$filenbpiece = $dir . "/vendu12mois.png";
$px = new BarGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$graph_data = $product->get_num_vente($socid);
$px->draw($filenbvente, $graph_data);
$px = new BarGraph();
$graph_data = $product->get_nb_vente($socid);
$px->draw($filenbpiece, $graph_data);
$px = new BarGraph();
$graph_data = $product->get_num_propal($socid);
$px->draw($filenbpropal, $graph_data);
$mesg = $langs->trans("ChartGenerated");
}
$h=0;
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans("Card");
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
$head[$h][1] = $langs->trans("Price");
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
$head[$h][1] = $langs->trans("Photos");
$h++;
if($product->type == 0)
{
if ($conf->stock->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
$head[$h][1] = $langs->trans('Stock');
$h++;
}
}
if ($conf->fournisseur->enabled)
{ {
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; if (! create_exdir($dir))
$head[$h][1] = $langs->trans("Suppliers"); {
$h++; $mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
}
} }
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; $img_propal_name = "propal12mois.png";
$head[$h][1] = $langs->trans("Statistics"); $filenbpropal = $dir . "/" . $img_propal_name;
$hselected=$h; $filenbvente = $dir . "/vente12mois.png";
$h++; $filenbpiece = $dir . "/vendu12mois.png";
$px = new BarGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$graph_data = $product->get_num_vente($socid);
$px->draw($filenbvente, $graph_data);
$px = new BarGraph();
$graph_data = $product->get_nb_vente($socid);
$px->draw($filenbpiece, $graph_data);
$px = new BarGraph();
$graph_data = $product->get_num_propal($socid);
$px->draw($filenbpropal, $graph_data);
$mesg = $langs->trans("ChartGenerated");
}
$h=0;
$head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans("Card");
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
$head[$h][1] = $langs->trans("Price");
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
$head[$h][1] = $langs->trans("Photos");
$h++;
if($product->type == 0)
{
if ($conf->stock->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
$head[$h][1] = $langs->trans('Stock');
$h++;
}
}
if ($conf->fournisseur->enabled)
{
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
$head[$h][1] = $langs->trans("Suppliers");
$h++;
}
$head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
$head[$h][1] = $langs->trans("Statistics");
$hselected=$h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
$head[$h][1] = $langs->trans('Bills'); $head[$h][1] = $langs->trans('Bills');
$h++; $h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>'; print '<td width="10%">'.$langs->trans("Ref").'</td><td colspan="2" width="40%">'.$product->ref.'</td>';
print '</tr>'; print '</tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td></tr>';
print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>'; print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>';
print '<td valign="top" rowspan="2">'; print '<td valign="top" rowspan="2">';
// Propals // Propals
if ($conf->propal->enabled) if ($conf->propal->enabled)
{ {
$langs->load("propal"); $langs->load("propal");
print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a> : '.$product->count_propale($socid); print '<a href="propal.php?id='.$product->id.'">'.$langs->trans("Proposals").'</a> : '.$product->count_propale($socid);
print " (Proposé à ".$product->count_propale_client($socid)." clients)<br>"; print " (Proposé à ".$product->count_propale_client($socid)." clients)<br>";
} }
// Commande // Commande
if ($conf->commande->enabled) if ($conf->commande->enabled)
{ {
$langs->load("orders"); $langs->load("orders");
print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a> : '.$product->count_facture($socid)."<br>"; print '<a href="commande.php?id='.$product->id.'">'.$langs->trans("Orders").'</a> : '.$product->count_facture($socid)."<br>";
} }
// Factures // Factures
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
$langs->load("bills"); $langs->load("bills");
print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a> : '.$product->count_facture($socid); print '<a href="facture.php?id='.$product->id.'">'.$langs->trans("Bills").'</a> : '.$product->count_facture($socid);
} }
print '</td></tr>'; print '</td></tr>';
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'; print '<tr><td>'.$langs->trans("Status").'</td><td>';
@ -187,71 +183,71 @@ if ($_GET["id"])
else print $langs->trans("NotOnSell"); else print $langs->trans("NotOnSell");
print '</td></tr>'; print '</td></tr>';
print "</table>"; print "</table>";
print '<br><table class="border" width="100%">'; print '<br><table class="border" width="100%">';
print '<tr class="liste_titre"><td width="50%" colspan="2" align="center">Nombre de ventes<br>sur les 12 derniers mois</td>'; print '<tr class="liste_titre"><td width="50%" colspan="2" align="center">Nombre de ventes<br>sur les 12 derniers mois</td>';
print '<td align="center" width="50%" colspan="2">Nombre de pièces vendues</td></tr>'; print '<td align="center" width="50%" colspan="2">Nombre de pièces vendues</td></tr>';
print '<tr><td align="center" colspan="2">'; print '<tr><td align="center" colspan="2">';
$file=$product->id.'/vente12mois.png'; $file=$product->id.'/vente12mois.png';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Ventes sur les 12 derniers mois">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Ventes sur les 12 derniers mois">';
print '</td><td align="center" colspan="2">'; print '</td><td align="center" colspan="2">';
$file=$product->id.'/vendu12mois.png'; $file=$product->id.'/vendu12mois.png';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de pièces vendues sur les 12 derniers mois">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de pièces vendues sur les 12 derniers mois">';
print '</td></tr><tr>'; print '</td></tr><tr>';
if (file_exists($filenbvente) && filemtime($filenbvente)) if (file_exists($filenbvente) && filemtime($filenbvente))
{ {
print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbvente),"%d %b %Y %H:%M:%S")).'</td>'; print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbvente),"%d %b %Y %H:%M:%S")).'</td>';
} }
else else
{ {
print '<td>'.$langs->trans("ChartNotGenerated").'</td>'; print '<td>'.$langs->trans("ChartNotGenerated").'</td>';
} }
print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td>'; print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td>';
if (file_exists($filenbpiece) && filemtime($filenbpiece)) if (file_exists($filenbpiece) && filemtime($filenbpiece))
{ {
print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).'</td>'; print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).'</td>';
} }
else else
{ {
print '<td>'.$langs->trans("ChartNotGenerated").'</td>'; print '<td>'.$langs->trans("ChartNotGenerated").'</td>';
} }
print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td></tr>'; print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td></tr>';
print '<tr><td colspan="4">Statistiques effectuées sur les factures payées uniquement</td></tr>'; print '<tr><td colspan="4">Statistiques effectuées sur les factures payées uniquement</td></tr>';
print '<tr class="liste_titre"><td width="50%" colspan="2" align="center">Nombre de propositions commerciales<br>sur les 12 derniers mois</td>'; print '<tr class="liste_titre"><td width="50%" colspan="2" align="center">Nombre de propositions commerciales<br>sur les 12 derniers mois</td>';
print '<td align="center" width="50%" colspan="2">-</td></tr>'; print '<td align="center" width="50%" colspan="2">-</td></tr>';
print '<tr><td align="center" colspan="2">'; print '<tr><td align="center" colspan="2">';
$file=$product->id.'/'.$img_propal_name; $file=$product->id.'/'.$img_propal_name;
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de propales sur les 12 derniers mois">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file='.urlencode($file).'" alt="Nombre de propales sur les 12 derniers mois">';
print '</td><td align="center" colspan="2">TODO AUTRE GRAPHIQUE'; print '</td><td align="center" colspan="2">TODO AUTRE GRAPHIQUE';
print '</td></tr><tr>'; print '</td></tr><tr>';
if (file_exists($filenbpropal) && filemtime($filenbpropal)) if (file_exists($filenbpropal) && filemtime($filenbpropal))
{ {
print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpropal),"%d %b %Y %H:%M:%S")).'</td>'; print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpropal),"%d %b %Y %H:%M:%S")).'</td>';
} }
else else
{ {
print '<td>'.$langs->trans("ChartNotGenerated").'</td>'; print '<td>'.$langs->trans("ChartNotGenerated").'</td>';
} }
print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td>'; print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td>';
if (file_exists($filenbpiece) && filemtime($filenbpiece33)) if (file_exists($filenbpiece) && filemtime($filenbpiece33))
{ {
print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).'</td>'; print '<td>'.$langs->trans("GeneratedOn",dolibarr_print_date(filemtime($filenbpiece),"%d %b %Y %H:%M:%S")).'</td>';
} }
else else
{ {
print '<td>'.$langs->trans("ChartNotGenerated").'</td>'; print '<td>'.$langs->trans("ChartNotGenerated").'</td>';
} }
print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td></tr>'; print '<td align="center">[<a href="fiche.php?id='.$product->id.'&amp;action=recalcul">'.$langs->trans("ReCalculate").'</a>]</td></tr>';
print '</table><br>'; print '</table><br>';
} }
} }