Fix: Debuggage et traduction module expedition.
This commit is contained in:
parent
27f3acedc4
commit
b7dcd6409a
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -24,10 +24,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/admin/expedition.php
|
\file htdocs/admin/expedition.php
|
||||||
\ingroup expedition
|
\ingroup expedition
|
||||||
\brief Page d'administration/configuration du module Expedition
|
\brief Page d'administration/configuration du module Expedition
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -37,80 +37,111 @@ $langs->load("sendings");
|
|||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) accessforbidden();
|
||||||
|
|
||||||
|
// positionne la variable pour le test d'affichage de l'icone
|
||||||
|
$expedition_addon_var_pdf = EXPEDITION_ADDON_PDF;
|
||||||
|
$expedition_default = EXPEDITION_ADDON;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
if ($_GET["action"] == 'set')
|
if ($_GET["action"] == 'set')
|
||||||
{
|
{
|
||||||
$file = DOL_DOCUMENT_ROOT . '/expedition/mods/methode_expedition_'.$_GET["value"].'.modules.php';
|
$file = DOL_DOCUMENT_ROOT . '/expedition/mods/methode_expedition_'.$_GET["value"].'.modules.php';
|
||||||
|
|
||||||
$classname = 'methode_expedition_'.$_GET["value"];
|
$classname = 'methode_expedition_'.$_GET["value"];
|
||||||
require_once($file);
|
require_once($file);
|
||||||
|
|
||||||
$obj = new $classname();
|
|
||||||
|
|
||||||
// Mise a jour statut
|
$obj = new $classname();
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition_methode set status='".$_GET["statut"]."'";
|
|
||||||
$sql.= " WHERE rowid = ".$obj->id;
|
|
||||||
print "$sql";
|
|
||||||
exit;
|
|
||||||
|
|
||||||
Header("Location: expedition.php");
|
// Mise a jour statut
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition_methode set status='".$_GET["statut"]."'";
|
||||||
|
$sql.= " WHERE rowid = ".$obj->id;
|
||||||
|
print "$sql";
|
||||||
|
exit;
|
||||||
|
|
||||||
|
Header("Location: expedition.php");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET["action"] == 'setpdf')
|
if ($_GET["action"] == 'setpdf')
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON_PDF';";
|
$db->begin();
|
||||||
$db->query($sql);
|
|
||||||
$sql='';
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON_PDF';";
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON_PDF','".$_GET["value"]."',0)";
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
if ($db->query($sql))
|
|
||||||
{
|
{
|
||||||
// la constante qui a été lue en avant du nouveau set
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON_PDF','".$_GET["value"]."',0)";
|
||||||
// on passe donc par une variable pour avoir un affichage cohérent
|
$resql=$db->query($sql);
|
||||||
$expedition_addon_var_pdf = $value;
|
if ($resql)
|
||||||
|
{
|
||||||
|
// la constante qui a été lue en avant du nouveau set
|
||||||
|
// on passe donc par une variable pour avoir un affichage cohérent
|
||||||
|
$expedition_addon_var_pdf = $value;
|
||||||
|
|
||||||
|
$db->commit();
|
||||||
|
|
||||||
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
Header("Location: expedition.php");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
llxHeader();
|
|
||||||
|
|
||||||
// positionne la variable pour le test d'affichage de l'icone
|
|
||||||
$expedition_addon_var_pdf = EXPEDITION_ADDON_PDF;
|
|
||||||
$expedition_default = EXPEDITION_DEFAULT;
|
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'setdef')
|
if ($_GET["action"] == 'setdef')
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON';";
|
$db->begin();
|
||||||
$db->query($sql);
|
|
||||||
$sql='';
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'EXPEDITION_ADDON';";
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON','".$value."',0)";
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
if ($db->query($sql))
|
|
||||||
{
|
{
|
||||||
// la constante qui a été lue en avant du nouveau set
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('EXPEDITION_ADDON','".$_GET["value"]."',0)";
|
||||||
// on passe donc par une variable pour avoir un affichage cohérent
|
$resql=$db->query($sql);
|
||||||
$expedition_default = $_GET["value"];
|
if ($resql)
|
||||||
|
{
|
||||||
|
// la constante qui a été lue en avant du nouveau set
|
||||||
|
// on passe donc par une variable pour avoir un affichage cohérent
|
||||||
|
$expedition_default = $_GET["value"];
|
||||||
|
$db->commit();
|
||||||
|
|
||||||
|
Header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
|
||||||
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
|
$dir = DOL_DOCUMENT_ROOT."/expedition/mods/";
|
||||||
|
|
||||||
/*
|
|
||||||
* Méthode de livraison
|
// Méthode de livraison
|
||||||
*/
|
|
||||||
|
|
||||||
print_titre($langs->trans("SendingsSetup"));
|
print_titre($langs->trans("SendingsSetup"));
|
||||||
|
|
||||||
@ -118,80 +149,77 @@ print "<br>";
|
|||||||
|
|
||||||
print_titre($langs->trans("SendingMethod"));
|
print_titre($langs->trans("SendingMethod"));
|
||||||
|
|
||||||
print '<table class="noborder">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
|
print '<td width="140">'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
|
||||||
print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>';
|
print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>';
|
||||||
print '<td align="center" colspan="2">'.$langs->trans("Default").'</td>';
|
print '<td align="center">'.$langs->trans("Default").'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if(is_dir($dir)) {
|
if(is_dir($dir)) {
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
$var=true;
|
||||||
while (($file = readdir($handle))!==false)
|
|
||||||
|
while (($file = readdir($handle))!==false)
|
||||||
{
|
{
|
||||||
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,19) == 'methode_expedition_')
|
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,19) == 'methode_expedition_')
|
||||||
{
|
{
|
||||||
$name = substr($file, 19, strlen($file) - 31);
|
$name = substr($file, 19, strlen($file) - 31);
|
||||||
$classname = substr($file, 0, strlen($file) - 12);
|
$classname = substr($file, 0, strlen($file) - 12);
|
||||||
|
|
||||||
require_once($dir.$file);
|
|
||||||
|
|
||||||
$obj = new $classname();
|
|
||||||
|
|
||||||
print '<tr class="pair"><td>';
|
|
||||||
echo $obj->name;
|
|
||||||
print "</td><td>\n";
|
|
||||||
|
|
||||||
print $obj->description;
|
|
||||||
|
|
||||||
print '</td><td align="center">';
|
|
||||||
|
|
||||||
|
|
||||||
print " ";
|
require_once($dir.$file);
|
||||||
print "</td><td>\n";
|
|
||||||
print '<a href="expedition.php?action=set&statut=1&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
|
||||||
|
|
||||||
|
$obj = new $classname();
|
||||||
print '</td><td align="center">';
|
|
||||||
|
$var=!$var;
|
||||||
if ($expedition_default == "$name")
|
print "<tr $bc[$var]><td>";
|
||||||
{
|
echo $obj->name;
|
||||||
print img_tick();
|
print "</td><td>\n";
|
||||||
}
|
|
||||||
else
|
print $obj->description;
|
||||||
{
|
|
||||||
print " ";
|
print '</td><td align="center">';
|
||||||
}
|
|
||||||
|
|
||||||
print "</td><td>\n";
|
print " ";
|
||||||
|
print "</td><td>\n";
|
||||||
print '<a href="expedition.php?action=setdef&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
print '<a href="expedition.php?action=set&statut=1&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
||||||
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
print '</td>';
|
||||||
|
|
||||||
|
// Default
|
||||||
|
print '<td align="center">';
|
||||||
|
if ($expedition_default == "$name")
|
||||||
|
{
|
||||||
|
print img_tick();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a href="expedition.php?action=setdef&value='.$name.'">'.$langs->trans("Default").'</a>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
|
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
/*
|
// PDF
|
||||||
*
|
|
||||||
* PDF
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
print_titre($langs->trans("SendingsReceiptModel"));
|
print_titre($langs->trans("SendingsReceiptModel"));
|
||||||
|
|
||||||
print '<table class="noborder">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
|
print '<td width="140">'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
|
||||||
print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>';
|
print '<td align="center" colspan="2">'.$langs->trans("Active").'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@ -201,54 +229,56 @@ $dir = DOL_DOCUMENT_ROOT."/expedition/mods/pdf/";
|
|||||||
|
|
||||||
if(is_dir($dir))
|
if(is_dir($dir))
|
||||||
{
|
{
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
$var=true;
|
||||||
|
|
||||||
while (($file = readdir($handle))!==false)
|
while (($file = readdir($handle))!==false)
|
||||||
{
|
{
|
||||||
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_')
|
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_')
|
||||||
{
|
{
|
||||||
$name = substr($file, 15, strlen($file) - 27);
|
$name = substr($file, 15, strlen($file) - 27);
|
||||||
$classname = substr($file, 0, strlen($file) - 12);
|
$classname = substr($file, 0, strlen($file) - 12);
|
||||||
|
|
||||||
print '<tr class="pair"><td>';
|
|
||||||
echo "$name";
|
|
||||||
print "</td><td>\n";
|
|
||||||
require_once($dir.$file);
|
|
||||||
$obj = new $classname();
|
|
||||||
|
|
||||||
print $obj->description;
|
|
||||||
|
|
||||||
|
|
||||||
print '</td><td align="center">';
|
$var=!$var;
|
||||||
|
print "<tr $bc[$var]><td>";
|
||||||
if ($expedition_addon_var_pdf == "$name")
|
print $name;
|
||||||
{
|
print "</td><td>\n";
|
||||||
print img_tick();
|
require_once($dir.$file);
|
||||||
}
|
$obj = new $classname();
|
||||||
else
|
|
||||||
{
|
print $obj->description;
|
||||||
print " ";
|
|
||||||
}
|
|
||||||
|
print '</td><td align="center">';
|
||||||
print "</td><td>\n";
|
|
||||||
|
if ($expedition_addon_var_pdf == "$name")
|
||||||
print '<a href="expedition.php?action=setpdf&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
{
|
||||||
|
print img_tick();
|
||||||
print '</td></tr>';
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
print " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</td><td>\n";
|
||||||
|
|
||||||
|
print '<a href="expedition.php?action=setpdf&value='.$name.'">'.$langs->trans("Activate").'</a>';
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
|
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
@ -161,5 +161,5 @@ print '<br>';
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter();
|
llxFooter('$Date$ - $Revision$');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -165,7 +165,7 @@ if ($_GET["action"] == 'facturee')
|
|||||||
$commande->classer_facturee();
|
$commande->classer_facturee();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->rights->commande->valider)
|
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET["id"]);
|
$commande->fetch($_GET["id"]);
|
||||||
@ -174,14 +174,14 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->ri
|
|||||||
$result = $commande->valid($user);
|
$result = $commande->valid($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == yes && $user->rights->commande->valider)
|
if ($_POST["action"] == 'confirm_cancel' && $_POST["confirm"] == 'yes' && $user->rights->commande->valider)
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET["id"]);
|
$commande->fetch($_GET["id"]);
|
||||||
$result = $commande->cancel($user);
|
$result = $commande->cancel($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == yes)
|
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
|
||||||
{
|
{
|
||||||
if ($user->rights->commande->supprimer )
|
if ($user->rights->commande->supprimer )
|
||||||
{
|
{
|
||||||
@ -744,40 +744,44 @@ else
|
|||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
if ($user->societe_id == 0 && $commande->statut < 3 && $_GET["action"] == '')
|
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
|
||||||
|
|
||||||
if ($conf->expedition->enabled && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
|
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$_GET["id"].'">'.$langs->trans("Send").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($commande->statut == 0)
|
|
||||||
{
|
|
||||||
if ($user->rights->commande->valider)
|
|
||||||
{
|
|
||||||
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
|
||||||
{
|
|
||||||
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($commande->statut == 1)
|
|
||||||
{
|
|
||||||
$nb_expedition = $commande->nb_expedition();
|
|
||||||
if ($user->rights->commande->valider && $nb_expedition == 0)
|
|
||||||
{
|
|
||||||
print '<a class="butAction" href="fiche.php?id='.$id.'&action=annuler">'.$langs->trans("Cancel").'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</div>";
|
/*
|
||||||
}
|
* Boutons actions
|
||||||
|
*/
|
||||||
|
if ($user->societe_id == 0 && $commande->statut < 3 && $_GET["action"] == '')
|
||||||
|
{
|
||||||
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
if ($conf->expedition->enabled && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$_GET["id"].'">'.$langs->trans("Send").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($commande->statut == 0)
|
||||||
|
{
|
||||||
|
if ($user->rights->commande->valider)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=valid">'.$langs->trans("Valid").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($commande->statut == 0 && $user->rights->commande->supprimer)
|
||||||
|
{
|
||||||
|
print '<a class="butActionDelete" href="fiche.php?id='.$id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($commande->statut == 1)
|
||||||
|
{
|
||||||
|
$nb_expedition = $commande->nb_expedition();
|
||||||
|
if ($user->rights->commande->valider && $nb_expedition == 0)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="fiche.php?id='.$id.'&action=annuler">'.$langs->trans("Cancel").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
|
}
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
@ -790,34 +794,34 @@ else
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||||
$sql .= " WHERE e.fk_commande = ". $commande->id;
|
$sql .= " WHERE e.fk_commande = ". $commande->id;
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
print_titre($langs->trans("Sendings"));
|
print_titre($langs->trans("Sendings"));
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print "<tr $bc[$var]><td>".$langs->trans("Sendings")."</td><td>".$langs->trans("Date")."</td></tr>\n";
|
print "<tr $bc[$var]><td>".$langs->trans("Sendings")."</td><td>".$langs->trans("Date")."</td></tr>\n";
|
||||||
|
|
||||||
$var=True;
|
$var=True;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print '<td><a href="../expedition/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowSending"),"sending").' '.$objp->ref.'</a></td>';
|
print '<td><a href="../expedition/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowSending"),"sending").' '.$objp->ref.'</a></td>';
|
||||||
print "<td>".dolibarr_print_date($objp->de)."</td></tr>\n";
|
print "<td>".dolibarr_print_date($objp->de)."</td></tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
print "</table>";
|
print "</table>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db);
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
print " </td><td>";
|
print " </td><td>";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -881,6 +885,7 @@ else
|
|||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
print '</td><td valign="top" width="50%">';
|
print '</td><td valign="top" width="50%">';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Classe la commande dans un projet
|
* Classe la commande dans un projet
|
||||||
* TODO finir le look & feel très moche
|
* TODO finir le look & feel très moche
|
||||||
@ -899,10 +904,6 @@ else
|
|||||||
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr></table></form>';
|
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Save").'"></td></tr></table></form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,13 +18,12 @@
|
|||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
* $Source$
|
* $Source$
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/expedition/commande.php
|
\file htdocs/expedition/commande.php
|
||||||
\ingroup expedition
|
\ingroup expedition
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -32,33 +31,30 @@ require("./pre.inc.php");
|
|||||||
$user->getrights('commande');
|
$user->getrights('commande');
|
||||||
$user->getrights('expedition');
|
$user->getrights('expedition');
|
||||||
if (!$user->rights->commande->lire)
|
if (!$user->rights->commande->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
require("../project.class.php");
|
require("../project.class.php");
|
||||||
require("../propal.class.php");
|
require("../propal.class.php");
|
||||||
require("../product/stock/entrepot.class.php");
|
require("../product/stock/entrepot.class.php");
|
||||||
|
|
||||||
|
// Sécurité accés client
|
||||||
|
if ($user->societe_id > 0)
|
||||||
|
{
|
||||||
|
$action = '';
|
||||||
|
$socidp = $user->societe_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sécurité accés client
|
* Actions
|
||||||
*/
|
*/
|
||||||
if ($user->societe_id > 0)
|
if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes')
|
||||||
{
|
{
|
||||||
$action = '';
|
$commande = new Commande($db);
|
||||||
$socidp = $user->societe_id;
|
$commande->fetch($_GET["id"]);
|
||||||
}
|
$result = $commande->cloture($user);
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == yes)
|
|
||||||
{
|
|
||||||
$commande = new Commande($db);
|
|
||||||
$commande->fetch($_GET["id"]);
|
|
||||||
$result = $commande->cloture($user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llxHeader('','Fiche commande','');
|
|
||||||
|
|
||||||
$html = new Form($db);
|
|
||||||
|
|
||||||
/* *************************************************************************** */
|
/* *************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
@ -66,333 +62,346 @@ $html = new Form($db);
|
|||||||
/* */
|
/* */
|
||||||
/* *************************************************************************** */
|
/* *************************************************************************** */
|
||||||
|
|
||||||
|
llxHeader('','Fiche commande','');
|
||||||
|
|
||||||
|
$html = new Form($db);
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["id"] > 0)
|
if ($_GET["id"] > 0)
|
||||||
{
|
{
|
||||||
$commande = New Commande($db);
|
$commande = New Commande($db);
|
||||||
if ( $commande->fetch($_GET["id"]) > 0)
|
if ( $commande->fetch($_GET["id"]) > 0)
|
||||||
{
|
{
|
||||||
$commande->livraison_array();
|
$commande->livraison_array();
|
||||||
|
|
||||||
$soc = new Societe($db);
|
|
||||||
$soc->fetch($commande->soc_id);
|
|
||||||
$author = new User($db);
|
|
||||||
$author->id = $commande->user_author_id;
|
|
||||||
$author->fetch();
|
|
||||||
|
|
||||||
$h=0;
|
$soc = new Societe($db);
|
||||||
|
$soc->fetch($commande->soc_id);
|
||||||
|
$author = new User($db);
|
||||||
|
$author->id = $commande->user_author_id;
|
||||||
|
$author->fetch();
|
||||||
|
|
||||||
if ($conf->commande->enabled && $user->rights->commande->lire)
|
$h=0;
|
||||||
{
|
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
|
if ($conf->commande->enabled && $user->rights->commande->lire)
|
||||||
$head[$h][1] = $langs->trans("OrderCard");
|
{
|
||||||
$h++;
|
$head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id;
|
||||||
|
$head[$h][1] = $langs->trans("OrderCard");
|
||||||
|
$h++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->expedition->enabled && $user->rights->expedition->lire)
|
|
||||||
{
|
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
|
|
||||||
$head[$h][1] = $langs->trans("SendingCard");
|
|
||||||
$hselected = $h;
|
|
||||||
$h++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conf->compta->enabled)
|
if ($conf->expedition->enabled && $user->rights->expedition->lire)
|
||||||
{
|
{
|
||||||
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
|
$head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id;
|
||||||
$head[$h][1] = $langs->trans("ComptaCard");
|
$head[$h][1] = $langs->trans("SendingCard");
|
||||||
$h++;
|
$hselected = $h;
|
||||||
|
$h++;
|
||||||
}
|
}
|
||||||
|
|
||||||
dolibarr_fiche_head($head, $hselected, $soc->nom." / ".$langs->trans("Order")." : $commande->ref");
|
|
||||||
/*
|
|
||||||
* Confirmation de la validation
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if ($_GET["action"] == 'cloture')
|
|
||||||
{
|
|
||||||
$html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture");
|
|
||||||
print "<br />";
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
if ($conf->compta->enabled)
|
||||||
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
|
{
|
||||||
print '<td width="30%">';
|
$head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id;
|
||||||
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
$head[$h][1] = $langs->trans("ComptaCard");
|
||||||
|
$h++;
|
||||||
print '<td width="50%">';
|
}
|
||||||
print $commande->statuts[$commande->statut];
|
|
||||||
print "</td></tr>";
|
|
||||||
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Date").'</td>';
|
|
||||||
print '<td width="30%">'.strftime("%A %d %B %Y",$commande->date)."</td>\n";
|
|
||||||
|
|
||||||
print '<td width="50%">Source : ' . $commande->sources[$commande->source] ;
|
dolibarr_fiche_head($head, $hselected, $soc->nom." / ".$langs->trans("Order")." : $commande->ref");
|
||||||
if ($commande->source == 0)
|
/*
|
||||||
{
|
* Confirmation de la validation
|
||||||
/* Propale */
|
*
|
||||||
$propal = new Propal($db);
|
*/
|
||||||
$propal->fetch($commande->propale_id);
|
if ($_GET["action"] == 'cloture')
|
||||||
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
|
{
|
||||||
}
|
$html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture");
|
||||||
print "</td></tr>";
|
print "<br />";
|
||||||
|
}
|
||||||
if ($commande->note)
|
|
||||||
{
|
|
||||||
print '<tr><td>Note</td></tr>';
|
|
||||||
print '<tr><td colspan="3">Note : '.nl2br($commande->note)."</td></tr>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table><br />';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lignes de commandes
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
echo '<table class="liste" width="100%" cellspacing="0" cellpadding="3">';
|
|
||||||
|
|
||||||
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
|
print '<table class="border" width="100%">';
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as l ";
|
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = l.fk_product)";
|
print '<td width="30%">';
|
||||||
$sql .= " WHERE l.fk_commande = ".$commande->id." AND p.fk_product_type <> 1 ORDER BY l.rowid";
|
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows();
|
|
||||||
$i = 0; $total = 0;
|
|
||||||
|
|
||||||
if ($num)
|
|
||||||
{
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td width="54%">'.$langs->trans("Description").'</td>';
|
|
||||||
print '<td align="center">Quan. Commandée</td>';
|
|
||||||
print '<td align="center">Quan. livrée</td>';
|
|
||||||
print '<td align="center">Reste à livrer</td>';
|
|
||||||
if (defined("MAIN_MODULE_STOCK"))
|
|
||||||
{
|
|
||||||
print '<td width="12%" align="center">Stock</td>';
|
|
||||||
}
|
|
||||||
print "</tr>\n";
|
|
||||||
}
|
|
||||||
$var=True;
|
|
||||||
$reste_a_livrer = array();
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$objp = $db->fetch_object();
|
|
||||||
print "<TR $bc[$var]>";
|
|
||||||
if ($objp->fk_product > 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
$product = new Product($db);
|
print '<td width="50%">';
|
||||||
$product->fetch($objp->fk_product);
|
print $commande->statuts[$commande->statut];
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
print '<td>';
|
print '<tr><td width="20%">'.$langs->trans("Date").'</td>';
|
||||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
print '<td width="30%">'.strftime("%A %d %B %Y",$commande->date)."</td>\n";
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<td>".stripslashes(nl2br($objp->description))."</TD>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<td align="center">'.$objp->qty.'</td>';
|
print '<td width="50%">Source : ' . $commande->sources[$commande->source] ;
|
||||||
|
if ($commande->source == 0)
|
||||||
|
{
|
||||||
|
/* Propale */
|
||||||
|
$propal = new Propal($db);
|
||||||
|
$propal->fetch($commande->propale_id);
|
||||||
|
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
|
||||||
|
}
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
print '<td align="center">';
|
if ($commande->note)
|
||||||
$quantite_livree = $commande->livraisons[$objp->fk_product];
|
{
|
||||||
print $quantite_livree;
|
print '<tr><td>'.$langs->trans("Note").'</td></tr>';
|
||||||
print '</td>';
|
print '<tr><td colspan="3">'.nl2br($commande->note)."</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
$reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree;
|
print '</table><br />';
|
||||||
$reste_a_livrer_x = $objp->qty - $quantite_livree;
|
|
||||||
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer_x;
|
|
||||||
print '<td align="center">';
|
|
||||||
print $reste_a_livrer[$objp->fk_product];
|
|
||||||
print '</td>';
|
|
||||||
|
|
||||||
if (defined("MAIN_MODULE_STOCK"))
|
|
||||||
{
|
|
||||||
if ($product->stock_reel < $reste_a_livrer_x)
|
|
||||||
{
|
|
||||||
print '<td align="center" class="alerte">'.$product->stock_reel.'</td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td align="center">'.$product->stock_reel.'</td>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print "</tr>";
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
$var=!$var;
|
|
||||||
}
|
|
||||||
$db->free();
|
|
||||||
print "</table>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if ($reste_a_livrer_total > 0 && $commande->brouillon == 0)
|
|
||||||
{
|
|
||||||
|
|
||||||
print '<form method="post" action="fiche.php">';
|
|
||||||
print '<input type="hidden" name="action" value="create">';
|
|
||||||
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
|
|
||||||
print '<br /><table class="border" width="100%">';
|
|
||||||
|
|
||||||
$entrepot = new Entrepot($db);
|
|
||||||
$langs->load("stocks");
|
|
||||||
|
|
||||||
print '<tr><td colspan="2">'.$langs->trans("NewSending").'</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>';
|
|
||||||
print '<td>';
|
|
||||||
$html->select_array("entrepot_id",$entrepot->list_array());
|
|
||||||
print '</td></tr>';
|
|
||||||
/*
|
|
||||||
print '<tr><td width="20%">Mode d\'expédition</td>';
|
|
||||||
print '<td>';
|
|
||||||
$html->select_array("entrepot_id",$entrepot->list_array());
|
|
||||||
print '</td></tr>';
|
|
||||||
*/
|
|
||||||
print '<tr><td colspan="2" align="center">';
|
|
||||||
if (sizeof($entrepot->list_array()))
|
|
||||||
{
|
|
||||||
|
|
||||||
print '<input type="submit" value="Créer">';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print 'Aucun entrepôt définit, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">definissez en un</a>';
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print "</table>";
|
|
||||||
print "</form>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Alerte de seuil
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
if ($reste_a_livrer_total > 0 && defined("MAIN_MODULE_STOCK"))
|
|
||||||
{
|
|
||||||
print '<br><table class="liste" width="100%"><tr>';
|
|
||||||
foreach ($reste_a_livrer as $key => $value)
|
|
||||||
{
|
|
||||||
if ($value > 0)
|
|
||||||
{
|
|
||||||
$sql = "SELECT e.label as entrepot, ps.reel, p.label ";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
|
|
||||||
$sql .= " WHERE e.rowid = ps.fk_entrepot AND ps.fk_product = p.rowid AND ps.fk_product = $key";
|
|
||||||
$sql .= " AND e.statut = 1 AND reel < $value";
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
$var=True;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obja = $db->fetch_object($resql);
|
|
||||||
print "<tr $bc[$var]>";
|
|
||||||
print '<td width="54%">'.$obja->label.'</td><td>'.$obja->entrepot.'</td><td><b>Stock : '.$obja->reel.'</b></td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$db->free($resql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print "</table>";
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* Lignes de commandes
|
||||||
*
|
*
|
||||||
|
*/
|
||||||
|
echo '<table class="liste" width="100%">';
|
||||||
|
|
||||||
|
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as l ";
|
||||||
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
|
||||||
|
$sql.= " WHERE l.fk_commande = ".$commande->id;
|
||||||
|
$sql.= " AND p.fk_product_type <> 1";
|
||||||
|
$sql.= " ORDER BY l.rowid";
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
$i = 0; $total = 0;
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>'.$langs->trans("Products").'</td>';
|
||||||
|
print '<td align="center">Quan. Commandée</td>';
|
||||||
|
print '<td align="center">Quan. livrée</td>';
|
||||||
|
print '<td align="center">Reste à livrer</td>';
|
||||||
|
if ($conf->stock->enabled)
|
||||||
|
{
|
||||||
|
print '<td align="center">Stock</td>';
|
||||||
|
}
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
$var=true;
|
||||||
|
$reste_a_livrer = array();
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object();
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
|
if ($objp->fk_product > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$product = new Product($db);
|
||||||
|
$product->fetch($objp->fk_product);
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<td>".stripslashes(nl2br($objp->description))."</td>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<td align="center">'.$objp->qty.'</td>';
|
||||||
|
|
||||||
|
print '<td align="center">';
|
||||||
|
$quantite_livree = $commande->livraisons[$objp->fk_product];
|
||||||
|
print $quantite_livree;
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
$reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree;
|
||||||
|
$reste_a_livrer_x = $objp->qty - $quantite_livree;
|
||||||
|
$reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer_x;
|
||||||
|
print '<td align="center">';
|
||||||
|
print $reste_a_livrer[$objp->fk_product];
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
if ($conf->stock->enabled)
|
||||||
|
{
|
||||||
|
if ($product->stock_reel < $reste_a_livrer_x)
|
||||||
|
{
|
||||||
|
print '<td align="center" class="alerte">'.$product->stock_reel.'</td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<td align="center">'.$product->stock_reel.'</td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "</tr>";
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
$var=!$var;
|
||||||
|
}
|
||||||
|
$db->free();
|
||||||
|
print "</table>";
|
||||||
|
|
||||||
|
if (! $num)
|
||||||
|
{
|
||||||
|
print $langs->trans("None").'<br>';
|
||||||
|
print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ($reste_a_livrer_total > 0 && $commande->brouillon == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
print '<form method="post" action="fiche.php">';
|
||||||
|
print '<input type="hidden" name="action" value="create">';
|
||||||
|
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
|
||||||
|
print '<br /><table class="border" width="100%">';
|
||||||
|
|
||||||
|
$entrepot = new Entrepot($db);
|
||||||
|
$langs->load("stocks");
|
||||||
|
|
||||||
|
print '<tr><td colspan="2">'.$langs->trans("NewSending").'</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td width="20%">'.$langs->trans("Warehouse").'</td>';
|
||||||
|
print '<td>';
|
||||||
|
$html->select_array("entrepot_id",$entrepot->list_array());
|
||||||
|
if (sizeof($entrepot->list_array()) <= 0)
|
||||||
|
{
|
||||||
|
print ' Aucun entrepôt définit, <a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?action=create">definissez en un</a>';
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
/*
|
||||||
|
print '<tr><td width="20%">Mode d\'expédition</td>';
|
||||||
|
print '<td>';
|
||||||
|
$html->select_array("entrepot_id",$entrepot->list_array());
|
||||||
|
print '</td></tr>';
|
||||||
|
*/
|
||||||
|
|
||||||
|
print "</table><br>";
|
||||||
|
print "</form>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Alerte de seuil
|
||||||
|
*/
|
||||||
|
if ($reste_a_livrer_total > 0 && $conf->stock->enabled)
|
||||||
|
{
|
||||||
|
print '<br><table class="liste" width="100%"><tr>';
|
||||||
|
foreach ($reste_a_livrer as $key => $value)
|
||||||
|
{
|
||||||
|
if ($value > 0)
|
||||||
|
{
|
||||||
|
$sql = "SELECT e.label as entrepot, ps.reel, p.label ";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e, ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
|
||||||
|
$sql .= " WHERE e.rowid = ps.fk_entrepot AND ps.fk_product = p.rowid AND ps.fk_product = $key";
|
||||||
|
$sql .= " AND e.statut = 1 AND reel < $value";
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
$var=True;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obja = $db->fetch_object($resql);
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
|
print '<td width="54%">'.$obja->label.'</td><td>'.$obja->entrepot.'</td><td><b>Stock : '.$obja->reel.'</b></td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$db->free($resql);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dolibarr_print_date($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "</table>";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Boutons Actions
|
||||||
*/
|
*/
|
||||||
if ($user->societe_id == 0)
|
if ($user->societe_id == 0)
|
||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
if ($user->rights->expedition->valider && $reste_a_livrer_total == 0 && $commande->statut < 3)
|
|
||||||
|
if ($user->rights->expedition->creer && $reste_a_livrer_total > 0 && $commande->brouillon == 0)
|
||||||
|
{
|
||||||
|
print '<a class="tabAction" href="fiche.php?action=create&commande_id='.$commande->id.'">'.$langs->trans("CreateSending").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->rights->commande->creer && $reste_a_livrer_total == 0 && $commande->statut < 3)
|
||||||
{
|
{
|
||||||
print '<a class="tabAction" href="commande.php?id='.$commande->id.'&action=cloture">'.$langs->trans("Close").'</a>';
|
print '<a class="tabAction" href="commande.php?id='.$commande->id.'&action=cloture">'.$langs->trans("Close").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Déjà livré
|
* Déjà livr
|
||||||
*
|
*/
|
||||||
*
|
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande, ed.qty as qty_livre, e.ref, e.rowid as expedition_id";
|
||||||
*/
|
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
|
||||||
$sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande, ed.qty as qty_livre, e.ref, e.rowid as expedition_id";
|
$sql .= " WHERE cd.fk_commande = ".$commande->id." AND cd.rowid = ed.fk_commande_ligne AND ed.fk_expedition = e.rowid";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e";
|
$sql .= " ORDER BY e.rowid DESC, cd.fk_product";
|
||||||
$sql .= " WHERE cd.fk_commande = ".$commande->id." AND cd.rowid = ed.fk_commande_ligne AND ed.fk_expedition = e.rowid";
|
$resql = $db->query($sql);
|
||||||
$sql .= " ORDER BY e.rowid DESC, cd.fk_product";
|
if ($resql)
|
||||||
$resql = $db->query($sql);
|
{
|
||||||
if ($resql)
|
$num = $db->num_rows($resql);
|
||||||
{
|
$i = 0; $total = 0;
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
$i = 0; $total = 0;
|
|
||||||
|
|
||||||
if ($num)
|
|
||||||
{
|
|
||||||
print '<br><table class="liste" width="100%"><tr>';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td width="54%">'.$langs->trans("Description").'</td>';
|
|
||||||
print '<td align="center">Quan. livrée</td>';
|
|
||||||
print '<td align="center">Expédition</td>';
|
|
||||||
|
|
||||||
print "</tr>\n";
|
if ($num)
|
||||||
|
{
|
||||||
$var=True;
|
print '<br><table class="liste" width="100%"><tr>';
|
||||||
while ($i < $num)
|
print '<tr class="liste_titre">';
|
||||||
{
|
print '<td width="54%">'.$langs->trans("Description").'</td>';
|
||||||
$objp = $db->fetch_object($resql);
|
print '<td align="center">Quan. livrée</td>';
|
||||||
print "<TR $bc[$var]>";
|
print '<td align="center">Expédition</td>';
|
||||||
if ($objp->fk_product > 0)
|
|
||||||
{
|
|
||||||
print '<td>';
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "<td>".stripslashes(nl2br($objp->description))."</TD>\n";
|
|
||||||
}
|
|
||||||
print '<td align="center">'.$objp->qty_livre.'</td>';
|
|
||||||
print '<td align="center"><a href="fiche.php?id='.$objp->expedition_id.'">'.$objp->ref.'</a></td>';
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</table>';
|
print "</tr>\n";
|
||||||
}
|
|
||||||
}
|
$var=True;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
|
print "<TR $bc[$var]>";
|
||||||
|
if ($objp->fk_product > 0)
|
||||||
|
{
|
||||||
|
print '<td>';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<td>".stripslashes(nl2br($objp->description))."</TD>\n";
|
||||||
|
}
|
||||||
|
print '<td align="center">'.$objp->qty_livre.'</td>';
|
||||||
|
print '<td align="center"><a href="fiche.php?id='.$objp->expedition_id.'">'.$objp->ref.'</a></td>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dolibarr_print_date($db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Commande non trouvée */
|
/* Commande non trouvée */
|
||||||
print "Commande inexistante ou accés refusé";
|
print "Commande inexistante";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
llxFooter('$Date$ - $Revision$');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -20,15 +20,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
\file htdocs/expedition/expedition.class.php
|
\file htdocs/expedition/expedition.class.php
|
||||||
\ingroup expedition
|
\ingroup expedition
|
||||||
\brief Fichier de la classe de gestion des expeditions
|
\brief Fichier de la classe de gestion des expeditions
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! \class Expedition
|
/** \class Expedition
|
||||||
\brief Classe de gestion des expeditions
|
\brief Classe de gestion des expeditions
|
||||||
*/
|
*/
|
||||||
class Expedition
|
class Expedition
|
||||||
@ -58,88 +58,94 @@ class Expedition
|
|||||||
|
|
||||||
$this->products = array();
|
$this->products = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Créé
|
* \brief Créé expédition en base
|
||||||
*
|
* \param user Objet du user qui cré
|
||||||
*
|
* \return int <0 si erreur, id expédition créée si ok
|
||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
||||||
$error = 0;
|
$error = 0;
|
||||||
/* On positionne en mode brouillon la commande */
|
/* On positionne en mode brouillon la commande */
|
||||||
$this->brouillon = 1;
|
$this->brouillon = 1;
|
||||||
|
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition, fk_commande";
|
||||||
|
if ($this->entrepot_id) $sql.= ", fk_entrepot";
|
||||||
|
$sql.= ")";
|
||||||
|
$sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition).",$this->commande_id";
|
||||||
|
if ($this->entrepot_id) $sql.= ", $this->entrepot_id";
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition");
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->commande = new Commande($this->db);
|
||||||
|
$this->commande->id = $this->commande_id;
|
||||||
|
$this->commande->fetch_lignes();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Insertion des produits dans la base
|
||||||
|
*/
|
||||||
|
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
if (! $this->create_line(0, $this->lignes[$i]->commande_ligne_id, $this->lignes[$i]->qty))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->user = $user;
|
/*
|
||||||
$this->db->begin();
|
*
|
||||||
|
*/
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition, fk_commande, fk_entrepot) ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->commande_id;
|
||||||
$sql .= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition).",$this->commande_id, $this->entrepot_id)";
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
if ( $this->db->query($sql) )
|
$error++;
|
||||||
{
|
}
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition");
|
|
||||||
|
if ($error==0)
|
||||||
/*
|
{
|
||||||
*
|
$this->db->commit();
|
||||||
*
|
return $this->id;
|
||||||
*/
|
}
|
||||||
|
else
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
{
|
||||||
if ($this->db->query($sql))
|
$error++;
|
||||||
{
|
$this->error=$this->db->error()." - sql=$sql";
|
||||||
|
$this->db->rollback();
|
||||||
$this->commande = new Commande($this->db);
|
return -3;
|
||||||
$this->commande->id = $this->commande_id;
|
}
|
||||||
$this->commande->fetch_lignes();
|
}
|
||||||
|
else
|
||||||
/*
|
{
|
||||||
* Insertion des produits dans la base
|
$error++;
|
||||||
*/
|
$this->error=$this->db->error()." - sql=$sql";
|
||||||
for ($i = 0 ; $i < sizeof($this->lignes) ; $i++)
|
$this->db->rollback();
|
||||||
{
|
return -2;
|
||||||
//TODO
|
}
|
||||||
if (! $this->create_line(0, $this->lignes[$i]->commande_ligne_id, $this->lignes[$i]->qty))
|
}
|
||||||
{
|
else
|
||||||
$error++;
|
{
|
||||||
}
|
$error++;
|
||||||
}
|
$this->error=$this->db->error()." - sql=$sql";
|
||||||
/*
|
$this->db->rollback();
|
||||||
*
|
return -1;
|
||||||
*
|
}
|
||||||
*/
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->commande_id;
|
|
||||||
if (! $this->db->query($sql))
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($error ==0)
|
|
||||||
{
|
|
||||||
$this->db->commit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->db->rollback();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
print $this->db->error() . '<b><br>'.$sql;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -215,58 +221,61 @@ class Expedition
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Valide l'expedition
|
* \brief Valide l'expedition
|
||||||
*
|
* \param user Objet de l'utilisateur qui valide
|
||||||
*
|
* \return int
|
||||||
*/
|
*/
|
||||||
function valid($user)
|
function valid($user)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
||||||
|
|
||||||
$result = 0;
|
$result = 0;
|
||||||
if ($user->rights->expedition->valider)
|
if ($user->rights->expedition->valider)
|
||||||
{
|
{
|
||||||
$this->ref = "EXP".$this->id;
|
$this->ref = "EXP".$this->id;
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='".$this->ref."', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='".$this->ref."', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id";
|
||||||
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";
|
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$result = 1;
|
$result = 1;
|
||||||
|
|
||||||
/*
|
// Si module stock géré et que expedition faite depuis un entrepot
|
||||||
* Enregistrement d'un mouvement de stock
|
if ($conf->stock->enabled && $this->entrepot_id)
|
||||||
* pour chaque ligne produit de l'expedition
|
{
|
||||||
*/
|
/*
|
||||||
|
* Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
||||||
$sql = "SELECT cd.fk_product, ed.qty ";
|
*/
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed";
|
|
||||||
$sql .= " WHERE ed.fk_expedition = $this->id AND cd.rowid = ed.fk_commande_ligne ";
|
$sql = "SELECT cd.fk_product, ed.qty ";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd , ".MAIN_DB_PREFIX."expeditiondet as ed";
|
||||||
if ($this->db->query($sql))
|
$sql .= " WHERE ed.fk_expedition = $this->id AND cd.rowid = ed.fk_commande_ligne ";
|
||||||
{
|
|
||||||
$num = $this->db->num_rows();
|
if ($this->db->query($sql))
|
||||||
$i=0;
|
{
|
||||||
while($i < $num)
|
$num = $this->db->num_rows();
|
||||||
{
|
$i=0;
|
||||||
$mouvS = new MouvementStock($this->db);
|
while($i < $num)
|
||||||
$obj = $this->db->fetch_object();
|
{
|
||||||
$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty, 0);
|
$mouvS = new MouvementStock($this->db);
|
||||||
$i++;
|
$obj = $this->db->fetch_object();
|
||||||
}
|
$mouvS->livraison($user, $obj->fk_product, $this->entrepot_id, $obj->qty, 0);
|
||||||
}
|
$i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
$result = -1;
|
else
|
||||||
print $this->db->error() . ' in ' . $sql;
|
{
|
||||||
}
|
$result = -1;
|
||||||
}
|
$this->error=$this->db->error()." - sql=".$sql;
|
||||||
return $result ;
|
}
|
||||||
|
}
|
||||||
|
return $result ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajoute un produit
|
* Ajoute un produit
|
||||||
*
|
*
|
||||||
|
|||||||
@ -21,11 +21,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/**
|
||||||
\file htdocs/expedition/fiche.php
|
\file htdocs/expedition/fiche.php
|
||||||
\ingroup expedition
|
\ingroup expedition
|
||||||
\brief Fiche descriptive d'une expedition
|
\brief Fiche descriptive d'une expedition
|
||||||
\version $Revision$
|
\version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -37,53 +37,59 @@ if (!$user->rights->expedition->lire)
|
|||||||
require("../propal.class.php");
|
require("../propal.class.php");
|
||||||
require("../product/stock/entrepot.class.php");
|
require("../product/stock/entrepot.class.php");
|
||||||
|
|
||||||
/*
|
// Sécurité accés client
|
||||||
* Sécurité accés client
|
|
||||||
*/
|
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
$action = '';
|
$action = '';
|
||||||
$socidp = $user->societe_id;
|
$socidp = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_POST["action"] == 'add')
|
if ($_POST["action"] == 'add')
|
||||||
{
|
{
|
||||||
$expedition = new Expedition($db);
|
$expedition = new Expedition($db);
|
||||||
|
|
||||||
$expedition->date_expedition = time();
|
$expedition->date_expedition = time();
|
||||||
$expedition->note = $_POST["note"];
|
$expedition->note = $_POST["note"];
|
||||||
$expedition->commande_id = $_POST["commande_id"];
|
$expedition->commande_id = $_POST["commande_id"];
|
||||||
$expedition->entrepot_id = $_POST["entrepot_id"];
|
$expedition->entrepot_id = $_POST["entrepot_id"];
|
||||||
|
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($expedition->commande_id);
|
$commande->fetch($expedition->commande_id);
|
||||||
$commande->fetch_lignes();
|
$commande->fetch_lignes();
|
||||||
|
|
||||||
for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++)
|
$db->begin();
|
||||||
|
|
||||||
|
for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++)
|
||||||
{
|
{
|
||||||
$qty = "qtyl".$i;
|
$qty = "qtyl".$i;
|
||||||
$idl = "idl".$i;
|
$idl = "idl".$i;
|
||||||
if ($_POST[$qty] > 0)
|
if ($_POST[$qty] > 0)
|
||||||
{
|
{
|
||||||
$expedition->addline($_POST[$idl],$_POST[$qty]);
|
$expedition->addline($_POST[$idl],$_POST[$qty]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret=$expedition->create($user);
|
||||||
|
if ($ret > 0)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
Header("Location: fiche.php?id=".$expedition->id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
$mesg='<div class="error">'.$expedition->error.'</div>';
|
||||||
|
$_GET["commande_id"]=$_POST["commande_id"];
|
||||||
|
$_GET["action"]='create';
|
||||||
}
|
}
|
||||||
|
|
||||||
$expedition->create($user);
|
|
||||||
|
|
||||||
$id = $expedition->id;
|
|
||||||
|
|
||||||
Header("Location:fiche.php?id=$id");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->expedition->valider)
|
if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->rights->expedition->valider)
|
||||||
{
|
{
|
||||||
$expedition = new Expedition($db);
|
$expedition = new Expedition($db);
|
||||||
@ -110,6 +116,7 @@ if ($_GET["action"] == 'pdf')
|
|||||||
$expedition->PdfWrite();
|
$expedition->PdfWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -120,18 +127,22 @@ $html = new Form($db);
|
|||||||
*
|
*
|
||||||
* Mode creation
|
* Mode creation
|
||||||
*
|
*
|
||||||
*
|
*********************************************************************/
|
||||||
************************************************************************/
|
if ($_GET["action"] == 'create')
|
||||||
if ($_POST["action"] == 'create')
|
|
||||||
{
|
{
|
||||||
llxHeader('','Fiche expedition','ch-expedition.html',$form_search);
|
llxHeader('','Fiche expedition','ch-expedition.html',$form_search);
|
||||||
|
|
||||||
print_titre("Créer une expédition");
|
print_titre($langs->trans("CreateASending"));
|
||||||
|
|
||||||
|
if ($mesg)
|
||||||
|
{
|
||||||
|
print $mesg.'<br>';
|
||||||
|
}
|
||||||
|
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->livraison_array();
|
$commande->livraison_array();
|
||||||
|
|
||||||
if ( $commande->fetch($_POST["commande_id"]))
|
if ( $commande->fetch($_GET["commande_id"]))
|
||||||
{
|
{
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->soc_id);
|
$soc->fetch($commande->soc_id);
|
||||||
@ -146,25 +157,25 @@ if ($_POST["action"] == 'create')
|
|||||||
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="commande_id" value="'.$commande->id.'">';
|
print '<input type="hidden" name="commande_id" value="'.$commande->id.'">';
|
||||||
print '<input type="hidden" name="entrepot_id" value="'.$_POST["entrepot_id"].'">';
|
print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
|
||||||
print '<table class="border" cellspacing="0" cellpadding="2" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tr><td width="20%">Client</td>';
|
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
|
||||||
print '<td width="30%"><b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
print '<td width="30%"><b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||||
|
|
||||||
print '<td width="50%" colspan="2">';
|
print '<td width="50%" colspan="2">';
|
||||||
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print "<tr><td>Date</td>";
|
print "<tr><td>".$langs->trans("Date")."</td>";
|
||||||
print "<td>".strftime("%A %d %B %Y",$commande->date)."</td>\n";
|
print "<td>".strftime("%A %d %B %Y",$commande->date)."</td>\n";
|
||||||
|
|
||||||
print '<td colspan="2" width="50%">Commande : ' . $commande->ref ;
|
print '<td colspan="2" width="50%">'.$langs->trans("Order").': ' . $commande->ref;
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
print '<tr><td>Entrepôt</td>';
|
print '<tr><td>'.$langs->trans("Warehouse").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$ents = $entrepot->list_array();
|
$ents = $entrepot->list_array();
|
||||||
print $ents[$_POST["entrepot_id"]];
|
print $ents[$_GET["entrepot_id"]];
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "<td>".$langs->trans("Author")."</td><td>$author->fullname</td>\n";
|
print "<td>".$langs->trans("Author")."</td><td>$author->fullname</td>\n";
|
||||||
|
|
||||||
@ -178,7 +189,7 @@ if ($_POST["action"] == 'create')
|
|||||||
* Lignes de commandes
|
* Lignes de commandes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
echo '<br><table border="0" width="100%" cellspacing="0" cellpadding="3">';
|
echo '<br><table class="noborder" width="100%">';
|
||||||
|
|
||||||
$lignes = $commande->fetch_lignes(1);
|
$lignes = $commande->fetch_lignes(1);
|
||||||
|
|
||||||
@ -195,16 +206,17 @@ if ($_POST["action"] == 'create')
|
|||||||
print '<td align="center">Quan. commandée</td>';
|
print '<td align="center">Quan. commandée</td>';
|
||||||
print '<td align="center">Quan. livrée</td>';
|
print '<td align="center">Quan. livrée</td>';
|
||||||
print '<td align="center">Quan. à livrer</td>';
|
print '<td align="center">Quan. à livrer</td>';
|
||||||
if (defined("MAIN_MODULE_STOCK"))
|
if ($conf->stock->enabled)
|
||||||
{
|
{
|
||||||
print '<td width="12%" align="center">Stock</td>';
|
print '<td width="12%" align="center">'.$langs->trans("Stock").'</td>';
|
||||||
}
|
}
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$var=True;
|
$var=true;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$ligne = $commande->lignes[$i];
|
$ligne = $commande->lignes[$i];
|
||||||
|
$var=!$var;
|
||||||
print "<tr $bc[$var]>\n";
|
print "<tr $bc[$var]>\n";
|
||||||
if ($ligne->product_id > 0)
|
if ($ligne->product_id > 0)
|
||||||
{
|
{
|
||||||
@ -216,7 +228,7 @@ if ($_POST["action"] == 'create')
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<td>".nl2br($ligne->description)."</TD>\n";
|
print "<td>".nl2br($ligne->description)."</td>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<td align="center">'.$ligne->qty.'</td>';
|
print '<td align="center">'.$ligne->qty.'</td>';
|
||||||
@ -236,7 +248,7 @@ if ($_POST["action"] == 'create')
|
|||||||
$quantite_commandee = $ligne->qty;
|
$quantite_commandee = $ligne->qty;
|
||||||
$quantite_a_livrer = $quantite_commandee - $quantite_livree;
|
$quantite_a_livrer = $quantite_commandee - $quantite_livree;
|
||||||
|
|
||||||
if (defined("MAIN_MODULE_STOCK"))
|
if ($conf->stock->enabled)
|
||||||
{
|
{
|
||||||
$stock = $product->stock_entrepot[$_POST["entrepot_id"]];
|
$stock = $product->stock_entrepot[$_POST["entrepot_id"]];
|
||||||
|
|
||||||
@ -267,13 +279,13 @@ if ($_POST["action"] == 'create')
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '<tr><td align="center" colspan="3"><input type="submit" value="Créer"></td></tr>';
|
print '<tr><td align="center" colspan="4"><br><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
|
||||||
print "</table>";
|
print "</table>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $db->error() . "<br>$sql";;
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -283,6 +295,7 @@ else
|
|||||||
/* */
|
/* */
|
||||||
/* *************************************************************************** */
|
/* *************************************************************************** */
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($_GET["id"] > 0)
|
if ($_GET["id"] > 0)
|
||||||
{
|
{
|
||||||
$expedition = New Expedition($db);
|
$expedition = New Expedition($db);
|
||||||
@ -345,8 +358,8 @@ else
|
|||||||
print '<input type="hidden" name="action" value="setremise">';
|
print '<input type="hidden" name="action" value="setremise">';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<br /><table class="border" cellspacing="0" cellpadding="2" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
print '<tr><td width="20%">Client</td>';
|
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
|
||||||
print '<td width="30%">';
|
print '<td width="30%">';
|
||||||
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||||
|
|
||||||
@ -354,17 +367,17 @@ else
|
|||||||
|
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
|
|
||||||
print "<tr><td>Commande</td>";
|
print '<tr><td>'.$langs->trans("Order").'</td>';
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref."</a></td>\n";
|
print '<td><a href="'.DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id.'">'.$commande->ref."</a></td>\n";
|
||||||
print '<td> </td><td> </td></tr>';
|
print '<td> </td><td> </td></tr>';
|
||||||
|
|
||||||
print "<tr><td>Date</td>";
|
print '<tr><td>'.$langs->trans("Date").'</td>';
|
||||||
print "<td>".strftime("%A %d %B %Y",$expedition->date)."</td>\n";
|
print "<td>".strftime("%A %d %B %Y",$expedition->date)."</td>\n";
|
||||||
|
|
||||||
$entrepot = new Entrepot($db);
|
$entrepot = new Entrepot($db);
|
||||||
$entrepot->fetch($expedition->entrepot_id);
|
$entrepot->fetch($expedition->entrepot_id);
|
||||||
|
|
||||||
print '<td width="20%">Entrepôt</td><td><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td></tr>';
|
print '<td width="20%">'.$langs->trans("Warehouse").'</td><td><a href="'.DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id.'">'.$entrepot->libelle.'</a></td></tr>';
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
@ -385,19 +398,20 @@ else
|
|||||||
{
|
{
|
||||||
$num_prod = $db->num_rows($resql);
|
$num_prod = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td width="54%">'.$langs->trans("Description").'</td>';
|
print '<td width="54%">'.$langs->trans("Products").'</td>';
|
||||||
print '<td align="center">Quan. commandée</td>';
|
print '<td align="center">Quan. commandée</td>';
|
||||||
print '<td align="center">Quan. livrée</td>';
|
print '<td align="center">Quan. livrée</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$var=True;
|
$var=true;
|
||||||
while ($i < $num_prod)
|
while ($i < $num_prod)
|
||||||
{
|
{
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
print "<TR $bc[$var]>";
|
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<td>';
|
print '<td>';
|
||||||
@ -422,25 +436,28 @@ else
|
|||||||
dolibarr_print_error($db);
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table><br>\n";
|
||||||
|
|
||||||
|
print "\n</div>\n";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$file = $expedition->pdf_filename;
|
$file = $expedition->pdf_filename;
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
print '<br /><table class="border" width="50%">';
|
print_titre($langs->trans("Documents"));
|
||||||
|
print '<table class="border" width="50%">';
|
||||||
print "<tr $bc[$var]><td>".$langs->trans("Sending")." PDF</td>";
|
print "<tr $bc[$var]><td>".$langs->trans("Sending")." PDF</td>";
|
||||||
|
|
||||||
$b = ereg_replace($conf->expedition->dir_output."/","",$file);
|
$b = ereg_replace($conf->expedition->dir_output."/","",$file);
|
||||||
|
|
||||||
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=expedition&file='.urlencode($b).'">'.basename($file).'</a></td>';
|
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=expedition&file='.urlencode($b).'">'.basename($file).'</a></td>';
|
||||||
print '<td align="right">'.filesize($file). ' bytes</td>';
|
print '<td align="right">'.filesize($file). ' bytes</td>';
|
||||||
print '<td align="right">'.strftime("%e %B %Y %H:%M:%S",filemtime($file)).'</td></tr>';
|
print '<td align="right">'.dolibarr_print_date(filemtime($file),"%d %B %Y %H:%M:%S").'</td></tr>';
|
||||||
print "</table>";
|
print "</table>";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n</div>\n";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -639,5 +656,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
llxFooter('$Date$ - $Revision$');
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/includes/fpdf/DolibarrPdfBarCode.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/includes/fpdf/DolibarrPdfBarCode.class.php';
|
||||||
|
|
||||||
Class ModelePdfExpedition extends DolibarrPdfBarCode
|
Class pdf_expedition extends DolibarrPdfBarCode
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition.class.php";
|
require_once DOL_DOCUMENT_ROOT."/expedition/mods/pdf/pdf_expedition.class.php";
|
||||||
|
|
||||||
|
|
||||||
Class pdf_expedition_rouget extends ModelePdfExpedition
|
Class pdf_expedition_rouget extends pdf_expedition
|
||||||
{
|
{
|
||||||
|
|
||||||
function pdf_expedition_rouget($db=0)
|
function pdf_expedition_rouget($db=0)
|
||||||
|
|||||||
@ -9,4 +9,6 @@ SearchASending=Search a sending
|
|||||||
StatisticsOfSendings=Statistics of sendings
|
StatisticsOfSendings=Statistics of sendings
|
||||||
NbOfSendings=Number of sendings
|
NbOfSendings=Number of sendings
|
||||||
SendingCard=Sending Card
|
SendingCard=Sending Card
|
||||||
NewSending=New sending
|
NewSending=New sending
|
||||||
|
CreateASending=Create a sending
|
||||||
|
CreateSending=Create sending
|
||||||
@ -10,3 +10,5 @@ StatisticsOfSendings=Statistiques des exp
|
|||||||
NbOfSendings=Nombre d'expéditions
|
NbOfSendings=Nombre d'expéditions
|
||||||
SendingCard=Fiche Expédition
|
SendingCard=Fiche Expédition
|
||||||
NewSending=Nouvelle expédition
|
NewSending=Nouvelle expédition
|
||||||
|
CreateASending=Créer une expedition
|
||||||
|
CreateSending=Créer expedition
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user