diff --git a/htdocs/boutique/commande/commande.class.php b/htdocs/boutique/commande/commande.class.php
index efdeade08cb..c5dfbcdfa52 100644
--- a/htdocs/boutique/commande/commande.class.php
+++ b/htdocs/boutique/commande/commande.class.php
@@ -17,117 +17,117 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
- /**
- \file htdocs/boutique/commande/commande.class.php
- \ingroup osc
- \brief Fichier de la classe des commandes OSC
- \version $Id$
-*/
+/**
+ \file htdocs/boutique/commande/commande.class.php
+ \ingroup osc
+ \brief Fichier de la classe des commandes OSC
+ \version $Id$
+ */
require_once(DOL_DOCUMENT_ROOT ."/core/address.class.php");
-/**
- \class Commande
- \brief Classe permettant la gestion des commandes OSC
-*/
+/**
+ \class Commande
+ \brief Classe permettant la gestion des commandes OSC
+ */
class Commande
{
- var $db ;
+ var $db ;
- var $id ;
- var $nom;
+ var $id ;
+ var $nom;
- function Commande($DB, $id=0) {
- $this->db = $DB;
- $this->id = $id ;
+ function Commande($DB, $id=0) {
+ $this->db = $DB;
+ $this->id = $id ;
- $this->billing_adr = new Address();
- $this->delivry_adr = new Address();
+ $this->billing_adr = new Address();
+ $this->delivry_adr = new Address();
- $this->total_ot_subtotal = 0;
- $this->total_ot_shipping = 0;
- }
-
- /*
- *
- *
- *
- */
- function fetch ($id) {
+ $this->total_ot_subtotal = 0;
+ $this->total_ot_shipping = 0;
+ }
- $sql = "SELECT orders_id, customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, last_modified, ".$this->db->pdate("date_purchased") . " as date_purchased, orders_status, orders_date_finished, currency, currency_value";
-
-
- $sql .= " FROM ".OSC_DB_NAME.".".OSC_DB_TABLE_PREFIX."orders WHERE orders_id = $id";
-
- $result = $this->db->query($sql) ;
-
- if ( $result )
- {
- $array = $this->db->fetch_array();
-
- $this->id = $array["orders_id"];
- $this->client_id = stripslashes($array["customers_id"]);
- $this->client_name = stripslashes($array["customers_name"]);
-
- $this->payment_method = stripslashes($array["payment_method"]);
-
- $this->date = dolibarr_print_date($array["date_purchased"],'dayhour');
-
- $this->delivery_adr->name = stripslashes($array["delivery_name"]);
- $this->delivery_adr->street = stripslashes($array["delivery_street_address"]);
- $this->delivery_adr->cp = stripslashes($array["delivery_postcode"]);
- $this->delivery_adr->city = stripslashes($array["delivery_city"]);
- $this->delivery_adr->country = stripslashes($array["delivery_country"]);
-
- $this->billing_adr->name = stripslashes($array["billing_name"]);
- $this->billing_adr->street = stripslashes($array["billing_street_address"]);
- $this->billing_adr->cp = stripslashes($array["billing_postcode"]);
- $this->billing_adr->city = stripslashes($array["billing_city"]);
- $this->billing_adr->country = stripslashes($array["billing_country"]);
-
- $this->db->free();
-
- /*
- * Totaux
+ /**
+ * \brief Get object and lines from database
+ * \param rowid id of object to load
+ * \param ref Ref of order
+ * \return int >0 si ok, <0 si ko
*/
- $sql = "SELECT value, class ";
- $sql .= " FROM ".OSC_DB_NAME.".".OSC_DB_TABLE_PREFIX."orders_total WHERE orders_id = $id";
+ function fetch ($id,$ref='')
+ {
+ $sql = "SELECT orders_id, customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, last_modified, ".$this->db->pdate("date_purchased") . " as date_purchased, orders_status, orders_date_finished, currency, currency_value";
+ $sql.= " FROM ".OSC_DB_NAME.".".OSC_DB_TABLE_PREFIX."orders";
+ $sql.= " WHERE orders_id = ".$id;
- $result = $this->db->query($sql) ;
+ $result = $this->db->query($sql) ;
- if ( $result )
+ if ( $result )
+ {
+ $array = $this->db->fetch_array();
+
+ $this->id = $array["orders_id"];
+ $this->client_id = stripslashes($array["customers_id"]);
+ $this->client_name = stripslashes($array["customers_name"]);
+
+ $this->payment_method = stripslashes($array["payment_method"]);
+
+ $this->date = dolibarr_print_date($array["date_purchased"],'dayhour');
+
+ $this->delivery_adr->name = stripslashes($array["delivery_name"]);
+ $this->delivery_adr->street = stripslashes($array["delivery_street_address"]);
+ $this->delivery_adr->cp = stripslashes($array["delivery_postcode"]);
+ $this->delivery_adr->city = stripslashes($array["delivery_city"]);
+ $this->delivery_adr->country = stripslashes($array["delivery_country"]);
+
+ $this->billing_adr->name = stripslashes($array["billing_name"]);
+ $this->billing_adr->street = stripslashes($array["billing_street_address"]);
+ $this->billing_adr->cp = stripslashes($array["billing_postcode"]);
+ $this->billing_adr->city = stripslashes($array["billing_city"]);
+ $this->billing_adr->country = stripslashes($array["billing_country"]);
+
+ $this->db->free();
+
+ /*
+ * Totaux
+ */
+ $sql = "SELECT value, class ";
+ $sql .= " FROM ".OSC_DB_NAME.".".OSC_DB_TABLE_PREFIX."orders_total WHERE orders_id = $id";
+
+ $result = $this->db->query($sql) ;
+
+ if ( $result )
{
- $num = $this->db->num_rows();
+ $num = $this->db->num_rows();
- while ($i < $num)
- {
- $array = $this->db->fetch_array($i);
- if ($array["class"] == 'ot_total')
- {
+ while ($i < $num)
+ {
+ $array = $this->db->fetch_array($i);
+ if ($array["class"] == 'ot_total')
+ {
$this->total_ot_total = $array["value"];
- }
- if ($array["class"] == 'ot_shipping')
- {
+ }
+ if ($array["class"] == 'ot_shipping')
+ {
$this->total_ot_shipping = $array["value"];
- }
- $i++;
- }
+ }
+ $i++;
+ }
}
- else
+ else
{
- print $this->db->error();
+ print $this->db->error();
}
- }
- else
- {
- print $this->db->error();
- }
-
- return $result;
- }
+ }
+ else
+ {
+ print $this->db->error();
+ }
+
+ return $result;
+ }
}
?>
diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index ba8badc5b7f..b63ace6119e 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -207,7 +207,7 @@ class Commande extends CommonObject
function valid($user)
{
global $conf,$langs;
-
+
$error=0;
// Protection
@@ -303,7 +303,7 @@ class Commande extends CommonObject
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
-
+
if ($error == 0)
{
$this->db->commit();
@@ -344,7 +344,7 @@ class Commande extends CommonObject
$this->error='Permission denied';
return -1;
}
-
+
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
@@ -379,7 +379,7 @@ class Commande extends CommonObject
return $result;
}
}
-
+
$this->statut=0;
$this->db->commit();
return 1;
@@ -435,7 +435,7 @@ class Commande extends CommonObject
if ($user->rights->commande->valider)
{
$this->db->begin();
-
+
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET fk_statut = -1';
$sql .= " WHERE rowid = $this->id AND fk_statut = 1 ;";
@@ -448,7 +448,7 @@ class Commande extends CommonObject
// We increment stock of product (and sub-products)
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot
$result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty);
-
+
if ($result > 0)
{
$this->db->commit();
@@ -461,7 +461,7 @@ class Commande extends CommonObject
return $result;
}
}
-
+
$this->db->commit();
return 1;
}
@@ -816,10 +816,12 @@ class Commande extends CommonObject
/**
- * \brief Load an order from database
- * \param rowid id de la commande a recuperer
+ * \brief Get object and lines from database
+ * \param rowid id of object to load
+ * \param ref Ref of invoice
+ * \return int >0 if OK, <0 if KO
*/
- function fetch($id)
+ function fetch($id,$ref='')
{
$sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut';
$sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.fk_cond_reglement, c.fk_mode_reglement';
@@ -834,89 +836,89 @@ class Commande extends CommonObject
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as cr ON (c.fk_cond_reglement = cr.rowid)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_pr as cp ON (cp.fk_commande = c.rowid)';
- $sql.= ' WHERE c.rowid = '.$id;
+ if ($ref) $sql.= " WHERE c.ref='".$ref."'";
+ else $sql.= " WHERE c.rowid=".$id;
dolibarr_syslog("Commande::fetch sql=$sql");
-
$result = $this->db->query($sql) ;
if ($result)
{
$obj = $this->db->fetch_object($result);
if ($obj)
- {
- $this->id = $obj->rowid;
- $this->ref = $obj->ref;
- $this->ref_client = $obj->ref_client;
- $this->socid = $obj->fk_soc;
- $this->statut = $obj->fk_statut;
- $this->user_author_id = $obj->fk_user_author;
- $this->total_ht = $obj->total_ht;
- $this->total_tva = $obj->total_tva;
- $this->total_ttc = $obj->total_ttc;
- $this->date = $obj->date_commande;
- $this->remise = $obj->remise;
- $this->remise_percent = $obj->remise_percent;
- $this->remise_absolue = $obj->remise_absolue;
- $this->source = $obj->source;
- $this->facturee = $obj->facturee;
- $this->note = $obj->note;
- $this->note_public = $obj->note_public;
- $this->projet_id = $obj->fk_projet;
- $this->modelpdf = $obj->model_pdf;
- $this->mode_reglement_id = $obj->fk_mode_reglement;
- $this->mode_reglement_code = $obj->mode_reglement_code;
- $this->mode_reglement = $obj->mode_reglement_libelle;
- $this->cond_reglement_id = $obj->fk_cond_reglement;
- $this->cond_reglement_code = $obj->cond_reglement_code;
- $this->cond_reglement = $obj->cond_reglement_libelle;
- $this->cond_reglement_facture = $obj->cond_reglement_libelle_facture;
- $this->date_livraison = $obj->date_livraison;
- $this->adresse_livraison_id = $obj->fk_adresse_livraison;
- $this->propale_id = $obj->fk_propale;
- $this->lignes = array();
-
- if ($this->statut == 0) $this->brouillon = 1;
+ {
+ $this->id = $obj->rowid;
+ $this->ref = $obj->ref;
+ $this->ref_client = $obj->ref_client;
+ $this->socid = $obj->fk_soc;
+ $this->statut = $obj->fk_statut;
+ $this->user_author_id = $obj->fk_user_author;
+ $this->total_ht = $obj->total_ht;
+ $this->total_tva = $obj->total_tva;
+ $this->total_ttc = $obj->total_ttc;
+ $this->date = $obj->date_commande;
+ $this->remise = $obj->remise;
+ $this->remise_percent = $obj->remise_percent;
+ $this->remise_absolue = $obj->remise_absolue;
+ $this->source = $obj->source;
+ $this->facturee = $obj->facturee;
+ $this->note = $obj->note;
+ $this->note_public = $obj->note_public;
+ $this->projet_id = $obj->fk_projet;
+ $this->modelpdf = $obj->model_pdf;
+ $this->mode_reglement_id = $obj->fk_mode_reglement;
+ $this->mode_reglement_code = $obj->mode_reglement_code;
+ $this->mode_reglement = $obj->mode_reglement_libelle;
+ $this->cond_reglement_id = $obj->fk_cond_reglement;
+ $this->cond_reglement_code = $obj->cond_reglement_code;
+ $this->cond_reglement = $obj->cond_reglement_libelle;
+ $this->cond_reglement_facture = $obj->cond_reglement_libelle_facture;
+ $this->date_livraison = $obj->date_livraison;
+ $this->adresse_livraison_id = $obj->fk_adresse_livraison;
+ $this->propale_id = $obj->fk_propale;
+ $this->lignes = array();
- $this->db->free();
-
- if ($this->propale_id)
- {
- $sqlp = "SELECT ref";
- $sqlp.= " FROM ".MAIN_DB_PREFIX."propal";
- $sqlp.= " WHERE rowid = ".$this->propale_id;
+ if ($this->statut == 0) $this->brouillon = 1;
- $resqlprop = $this->db->query($sqlp);
+ $this->db->free();
- if ($resqlprop)
- {
- $objp = $this->db->fetch_object($resqlprop);
- $this->propale_ref = $objp->ref;
- $this->db->free($resqlprop);
- }
- }
+ if ($this->propale_id)
+ {
+ $sqlp = "SELECT ref";
+ $sqlp.= " FROM ".MAIN_DB_PREFIX."propal";
+ $sqlp.= " WHERE rowid = ".$this->propale_id;
- /*
- * Lignes
- */
- $result=$this->fetch_lines();
- if ($result < 0)
- {
- return -3;
- }
- return 1;
- }
- else
- {
- dolibarr_syslog('Commande::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql);
- $this->error='Order with id '.$rowid.' not found sql='.$sql;
- return -2;
- }
+ $resqlprop = $this->db->query($sqlp);
+
+ if ($resqlprop)
+ {
+ $objp = $this->db->fetch_object($resqlprop);
+ $this->propale_ref = $objp->ref;
+ $this->db->free($resqlprop);
+ }
+ }
+
+ /*
+ * Lignes
+ */
+ $result=$this->fetch_lines();
+ if ($result < 0)
+ {
+ return -3;
+ }
+ return 1;
+ }
+ else
+ {
+ dolibarr_syslog('Commande::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql);
+ $this->error='Order with id '.$rowid.' not found sql='.$sql;
+ return -2;
+ }
}
else
{
dolibarr_syslog('Commande::Fetch Error rowid='.$rowid.' Erreur dans fetch de la commande');
- $this->error=$this->db->error();
- return -1;
+ $this->error=$this->db->error();
+ return -1;
}
}
@@ -1812,7 +1814,7 @@ class Commande extends CommonObject
global $conf, $user;
$now=gmmktime();
-
+
$this->nbtodo=$this->nbtodolate=0;
$clause = "WHERE";
diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php
index 38f2fa9fb91..82a379081d2 100644
--- a/htdocs/commande/contact.php
+++ b/htdocs/commande/contact.php
@@ -154,14 +154,15 @@ $contactstatic=new Contact($db);
/* Mode vue et edition */
/* */
/* *************************************************************************** */
-if ( isset($mesg))
- print $mesg;
-$id = $_GET["id"];
-if ($id > 0)
+if (isset($mesg)) print $mesg;
+
+$id = $_GET['id'];
+$ref= $_GET['ref'];
+if ($id > 0 || ! empty($ref))
{
$langs->trans("OrderCard");
- $commande = New Commande($db);
- if ( $commande->fetch($_GET['id'], $user->societe_id) > 0)
+ $commande = new Commande($db);
+ if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
{
$soc = new Societe($db, $commande->socid);
$soc->fetch($commande->socid);
@@ -178,7 +179,7 @@ if ($id > 0)
// Ref
print '
'.$langs->trans("Ref").' ';
- print $commande->ref;
+ print $html->showrefnav($commande,'ref','',1,'ref','ref');
print " ";
// Ref commande client
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index e902411cd55..2dae3cf5a39 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -20,11 +20,11 @@
*/
/**
- \file htdocs/commande/document.php
- \ingroup order
- \brief Page de gestion des documents attachees a une commande
- \version $Id$
-*/
+ \file htdocs/commande/document.php
+ \ingroup order
+ \brief Page de gestion des documents attachees a une commande
+ \version $Id$
+ */
require('./pre.inc.php');
require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php');
@@ -32,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php");
if (!$user->rights->commande->lire)
- accessforbidden();
+accessforbidden();
$langs->load('companies');
//$langs->load("bills");
@@ -42,10 +42,10 @@ $id=empty($_GET['id']) ? 0 : intVal($_GET['id']);
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Security check
-if ($user->societe_id > 0)
+if ($user->societe_id > 0)
{
unset($_GET["action"]);
- $action='';
+ $action='';
$socid = $user->societe_id;
}
@@ -62,63 +62,70 @@ $pageprev = $page - 1;
$pagenext = $page + 1;
+$id = $_GET['id'];
+$ref= $_GET['ref'];
$commande = new Commande($db);
-if (!$commande->fetch($id)) {
- dolibarr_print_error($db);
+if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
+{
+ dolibarr_print_error($db);
}
+
/*
* Actions
*/
-
+
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
- $upload_dir = $conf->commande->dir_output . "/" . sanitizeFileName($commande->ref);
- if (! is_dir($upload_dir)) create_exdir($upload_dir);
-
- if (is_dir($upload_dir))
- {
- if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0) > 0)
+ $upload_dir = $conf->commande->dir_output . "/" . sanitizeFileName($commande->ref);
+ if (! is_dir($upload_dir)) create_exdir($upload_dir);
+
+ if (is_dir($upload_dir))
{
+ if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0) > 0)
+ {
$mesg = ''.$langs->trans("FileTransferComplete").'
';
//print_r($_FILES);
- }
- else
- {
+ }
+ else
+ {
// Echec transfert (fichier dépassant la limite ?)
$mesg = ''.$langs->trans("ErrorFileNotUploaded").'
';
// print_r($_FILES);
+ }
}
- }
}
// Delete
if ($action=='delete')
{
- $upload_dir = $conf->commande->dir_output . "/" . sanitizeFileName($commande->ref);
- $file = $upload_dir . '/' . urldecode($_GET['urlfile']);
- dol_delete_file($file);
- $mesg = ''.$langs->trans("FileWasRemoved").'
';
+ $upload_dir = $conf->commande->dir_output . "/" . sanitizeFileName($commande->ref);
+ $file = $upload_dir . '/' . urldecode($_GET['urlfile']);
+ dol_delete_file($file);
+ $mesg = ''.$langs->trans("FileWasRemoved").'
';
}
/*
- * Affichage
+ * View
*/
-if ($id > 0)
-{
- llxHeader();
- $upload_dir = $conf->commande->dir_output.'/'.sanitizeFileName($commande->ref);
-
- $societe = new Societe($db);
- $societe->fetch($commande->socid);
-
- $head = commande_prepare_head($commande);
- dolibarr_fiche_head($head, 'documents', $langs->trans('CustomerOrder'));
-
-
+llxHeader();
+
+$html = new Form($db);
+
+if ($id > 0 || ! empty($ref))
+{
+ $upload_dir = $conf->commande->dir_output.'/'.sanitizeFileName($commande->ref);
+
+ $societe = new Societe($db);
+ $societe->fetch($commande->socid);
+
+ $head = commande_prepare_head($commande);
+ dolibarr_fiche_head($head, 'documents', $langs->trans('CustomerOrder'));
+
+
// Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
$totalsize=0;
@@ -126,35 +133,37 @@ if ($id > 0)
{
$totalsize+=$file['size'];
}
-
-
- print '';
-
- // Ref
- print ''.$langs->trans('Ref').' '.$commande->ref.' ';
-
- print ''.$langs->trans('Company').' '.$societe->getNomUrl(1).' ';
- print ''.$langs->trans("NbOfAttachedFiles").' '.sizeof($filearray).' ';
- print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
- print "
\n";
- print "\n";
- if ($mesg) { print $mesg." "; }
-
+ print '';
+
+ // Ref
+ print ''.$langs->trans('Ref').' ';
+ print $html->showrefnav($commande,'ref','',1,'ref','ref');
+ print ' ';
+
+ print ''.$langs->trans('Company').' '.$societe->getNomUrl(1).' ';
+ print ''.$langs->trans("NbOfAttachedFiles").' '.sizeof($filearray).' ';
+ print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
+ print "
\n";
+ print "\n";
+
+ if ($mesg) { print $mesg." "; }
+
+
// Affiche formulaire upload
- $formfile=new FormFile($db);
+ $formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/commande/document.php?id='.$commande->id);
-
-
+
+
// List of document
$param='&id='.$commande->id;
$formfile->list_of_documents($filearray,$commande,'commande',$param);
-
+
}
else
{
- Header('Location: index.php');
+ Header('Location: index.php');
}
$db->close();
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 59342688df6..f837a5a8264 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1136,122 +1136,128 @@ else
/* Mode vue et edition */
/* */
/* *************************************************************************** */
+ $now=gmmktime();
+
$id = $_GET['id'];
- if ($id > 0)
+ $ref= $_GET['ref'];
+ if ($id > 0 || ! empty($ref))
{
if ($mesg) print $mesg.' ';
$commande = new Commande($db);
- if ( $commande->fetch($_GET['id']) > 0)
+ $result=$commande->fetch($_GET['id'],$_GET['ref']);
+ if ($result > 0)
{
- $soc = new Societe($db);
- $soc->fetch($commande->socid);
+ $soc = new Societe($db);
+ $soc->fetch($commande->socid);
- $author = new User($db);
- $author->id = $commande->user_author_id;
- $author->fetch();
+ $author = new User($db);
+ $author->id = $commande->user_author_id;
+ $author->fetch();
- $head = commande_prepare_head($commande);
- dolibarr_fiche_head($head, 'order', $langs->trans("CustomerOrder"));
+ $head = commande_prepare_head($commande);
+ dolibarr_fiche_head($head, 'order', $langs->trans("CustomerOrder"));
- /*
- * Confirmation de la suppression de la commande
- */
- if ($_GET['action'] == 'delete')
- {
- $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete');
- print ' ';
- }
+ /*
+ * Confirmation de la suppression de la commande
+ */
+ if ($_GET['action'] == 'delete')
+ {
+ $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete');
+ print ' ';
+ }
- /*
- * Confirmation de la validation
- */
- if ($_GET['action'] == 'validate')
- {
- // on verifie si la facture est en numerotation provisoire
- $ref = substr($commande->ref, 1, 4);
- if ($ref == 'PROV')
- {
- $num = $commande->getNextNumRef($soc);
- }
- else
- {
- $num = $commande->ref;
- }
-
- $text=$langs->trans('ConfirmValidateOrder',$num);
- $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_validate');
- print ' ';
- }
+ /*
+ * Confirmation de la validation
+ */
+ if ($_GET['action'] == 'validate')
+ {
+ // on verifie si la facture est en numerotation provisoire
+ $ref = substr($commande->ref, 1, 4);
+ if ($ref == 'PROV')
+ {
+ $num = $commande->getNextNumRef($soc);
+ }
+ else
+ {
+ $num = $commande->ref;
+ }
- /*
- * Confirmation de la cloture
- */
- if ($_GET['action'] == 'close')
- {
- $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close');
- print ' ';
- }
+ $text=$langs->trans('ConfirmValidateOrder',$num);
+ $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('ValidateOrder'), $text, 'confirm_validate');
+ print ' ';
+ }
- /*
- * Confirmation de l'annulation
- */
- if ($_GET['action'] == 'cancel')
- {
- $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel');
- print ' ';
- }
+ /*
+ * Confirmation de la cloture
+ */
+ if ($_GET['action'] == 'close')
+ {
+ $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('CloseOrder'), $langs->trans('ConfirmCloseOrder'), 'confirm_close');
+ print ' ';
+ }
- /*
- * Confirmation de la suppression d'une ligne produit
- */
- if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
- {
- $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline');
- print ' ';
- }
+ /*
+ * Confirmation de l'annulation
+ */
+ if ($_GET['action'] == 'cancel')
+ {
+ $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('Cancel'), $langs->trans('ConfirmCancelOrder'), 'confirm_cancel');
+ print ' ';
+ }
- /*
- * Commande
- */
- $nbrow=8;
- if ($conf->projet->enabled) $nbrow++;
+ /*
+ * Confirmation de la suppression d'une ligne produit
+ */
+ if ($_GET['action'] == 'ask_deleteline' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
+ {
+ $html->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&lineid='.$_GET["lineid"], $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline');
+ print ' ';
+ }
- print '';
+ /*
+ * Commande
+ */
+ $nbrow=8;
+ if ($conf->projet->enabled) $nbrow++;
- // Ref
- print ''.$langs->trans('Ref').' ';
- print ''.$commande->ref.' ';
- print ' ';
+ print '';
- // Ref commande client
- print '';
- print '';
- print ' ';
- if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
- {
- print '';
- }
- else
- {
- print $commande->ref_client;
- }
- print ' ';
- print ' ';
+ // Ref
+ print ''.$langs->trans('Ref').' ';
+ print '';
+ print $html->showrefnav($commande,'ref','',1,'ref','ref');
+ print ' ';
+ print ' ';
+
+ // Ref commande client
+ print '';
+ print '';
+ print ' ';
+ if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder')
+ {
+ print '';
+ }
+ else
+ {
+ print $commande->ref_client;
+ }
+ print ' ';
+ print ' ';
- // Societe
- print ''.$langs->trans('Company').' ';
- print ''.$soc->getNomUrl(1).' ';
- print ' ';
+ // Societe
+ print ''.$langs->trans('Company').' ';
+ print ''.$soc->getNomUrl(1).' ';
+ print ' ';
// Ligne info remises tiers
print ''.$langs->trans('Discounts').' ';
diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php
index 1b2870512ba..dc30f43ca14 100644
--- a/htdocs/commande/note.php
+++ b/htdocs/commande/note.php
@@ -16,16 +16,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
*/
/**
- \file htdocs/commande/note.php
- \ingroup commande
- \brief Fiche de notes sur une commande
- \version $Revision$
-*/
+ \file htdocs/commande/note.php
+ \ingroup commande
+ \brief Fiche de notes sur une commande
+ \version $Id$
+ */
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php');
@@ -33,27 +31,32 @@ require_once(DOL_DOCUMENT_ROOT.'/lib/order.lib.php');
$socid=isset($_GET["socid"])?$_GET["socid"]:isset($_POST["socid"])?$_POST["socid"]:"";
if (!$user->rights->commande->lire)
- accessforbidden();
+accessforbidden();
$langs->load("companies");
$langs->load("bills");
$langs->load("orders");
// Sécurité accés
-if ($user->societe_id > 0)
+if ($user->societe_id > 0)
{
- unset($_GET["action"]);
- $socid = $user->societe_id;
+ unset($_GET["action"]);
+ $socid = $user->societe_id;
}
+$id = $_GET['id'];
+$ref= $_GET['ref'];
$commande = new Commande($db);
-$commande->fetch($_GET["id"]);
+if (! $commande->fetch($_GET['id'],$_GET['ref']) > 0)
+{
+ dolibarr_print_error($db);
+}
-/******************************************************************************/
-/* Actions */
-/******************************************************************************/
+/*
+ * Actions
+ */
if ($_POST["action"] == 'update' && $user->rights->commande->creer)
{
@@ -61,7 +64,7 @@ if ($_POST["action"] == 'update' && $user->rights->commande->creer)
$resPrivateNote=$commande->update_note($_POST["note"]);
$resPublicNote=$commande->update_note_public($_POST["note_public"]);
-
+
if ($resPrivateNote < 0 || $resPublicNote < 0)
{
$mesg=''.$commande->error.'
';
@@ -75,77 +78,77 @@ if ($_POST["action"] == 'update' && $user->rights->commande->creer)
-/******************************************************************************/
-/* Affichage fiche */
-/******************************************************************************/
+/*
+ * View
+ */
llxHeader();
$html = new Form($db);
-if ($_GET["id"])
+if ($id > 0 || ! empty($ref))
{
$soc = new Societe($db, $commande->socid);
- $soc->fetch($commande->socid);
-
- $head = commande_prepare_head($commande);
-
- dolibarr_fiche_head($head, 'note', $langs->trans("CustomerOrder"));
-
- print '';
+ $soc->fetch($commande->socid);
+
+ $head = commande_prepare_head($commande);
+
+ dolibarr_fiche_head($head, 'note', $langs->trans("CustomerOrder"));
+
+ print '';
// Ref
print ''.$langs->trans("Ref").' ';
- print $commande->ref;
+ print $html->showrefnav($commande,'ref','',1,'ref','ref');
print " ";
// Ref commande client
print '';
- print '';
+ print '';
print $langs->trans('RefCustomer').' ';
- print ' ';
- print '
';
- print ' ';
+ print ' ';
+ print '
';
+ print ' ';
print $commande->ref_client;
print ' ';
print ' ';
-
+
// Customer
print "".$langs->trans("Company")." ";
print ''.$soc->getNomUrl(1).' ';
// Note publique
- print ''.$langs->trans("NotePublic").' : ';
+ print ''.$langs->trans("NotePublic").' : ';
print '';
- if ($_GET["action"] == 'edit')
- {
- print ' ";
+ if ($_GET["action"] == 'edit')
+ {
+ print 'id.'">';
+ print ' ';
+ print ''.$commande->note_public." ";
+ }
+ else
+ {
+ print ($commande->note_public?nl2br($commande->note_public):" ");
+ }
+ print "";
// Note privée
if (! $user->societe_id)
{
print ''.$langs->trans("NotePrivate").' : ';
print '';
- if ($_GET["action"] == 'edit')
- {
- print ''.$commande->note." ";
- }
+ if ($_GET["action"] == 'edit')
+ {
+ print ''.$commande->note." ";
+ }
else
{
- print ($commande->note?nl2br($commande->note):" ");
+ print ($commande->note?nl2br($commande->note):" ");
}
print " ";
}
print "
";
-
+
if ($_GET["action"] == 'edit')
{
print '';
@@ -153,21 +156,21 @@ if ($_GET["id"])
print ' ';
print '';
}
-
+
print '';
-
+
/*
- * Actions
- */
-
- print '';
+ * Actions
+ */
+
+ print '
";
+ print "
";
}
$db->close();
diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php
index 2f8a808e15e..1de23104603 100644
--- a/htdocs/compta/commande/fiche.php
+++ b/htdocs/compta/commande/fiche.php
@@ -105,22 +105,21 @@ if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer)
}
-llxHeader('',$langs->trans("OrderCard"),"Commande");
+/*
+ * View
+ */
+llxHeader('',$langs->trans("OrderCard"),"Commande");
$html = new Form($db);
$formfile = new FormFile($db);
-/* *************************************************************************** */
-/* */
-/* Mode vue et edition */
-/* */
-/* *************************************************************************** */
-
-if ($_GET["id"] > 0)
+$id = $_GET['id'];
+$ref= $_GET['ref'];
+if ($id > 0 || ! empty($ref))
{
$commande = new Commande($db);
- if ( $commande->fetch($_GET["id"]) > 0)
+ if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
{
$soc = new Societe($db);
$soc->fetch($commande->socid);
@@ -142,7 +141,9 @@ if ($_GET["id"] > 0)
// Ref
print ''.$langs->trans('Ref').' ';
- print ''.$commande->ref.' ';
+ print '';
+ print $html->showrefnav($commande,'ref','',1,'ref','ref');
+ print ' ';
print ' ';
// Ref commande client
diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php
index 7e05b69a90d..2305ebbb417 100644
--- a/htdocs/expedition/commande.php
+++ b/htdocs/expedition/commande.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2005 Laurent Destailleur
+ * Copyright (C) 2005-2009 Laurent Destailleur
* Copyright (C) 2005-2008 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
@@ -123,10 +123,12 @@ $formfile = new FormFile($db);
llxHeader('',$langs->trans("OrderCard"));
-if ($_GET["id"] > 0)
+$id = $_GET['id'];
+$ref= $_GET['ref'];
+if ($id > 0 || ! empty($ref))
{
$commande = new Commande($db);
- if ( $commande->fetch($_GET["id"]) > 0)
+ if ( $commande->fetch($_GET['id'],$_GET['ref']) > 0)
{
$commande->loadExpeditions(1);
@@ -158,7 +160,9 @@ if ($_GET["id"] > 0)
// Ref
print ''.$langs->trans('Ref').' ';
- print ''.$commande->ref.' ';
+ print '';
+ print $html->showrefnav($commande,'ref','',1,'ref','ref');
+ print ' ';
print ' ';
// Ref commande client
@@ -507,72 +511,85 @@ if ($_GET["id"] > 0)
print '';
// Bouton expedier sans gestion des stocks
- if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer)
- {
- print '
'.$langs->trans("NewSending").' ';
+ if (! $conf->stock->enabled && ! $commande->brouillon)
+ {
+ if ($user->rights->expedition->creer)
+ {
+ print '
'.$langs->trans("NewSending").' ';
+ if ($reste_a_livrer_total <= 0)
+ {
+ print ' '.img_warning($langs->trans("WarningNoQtyLeftToSend"));
+ }
+ }
+ else
+ {
+ print '
'.$langs->trans("NewSending").' ';
+ }
}
print "
";
}
// Bouton expedier avec gestion des stocks
-
- print '';
-
- if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer)
+ if ($conf->stock->enabled && $commande->statut > 0 && $commande->statut < 3)
{
- print_titre($langs->trans("NewSending"));
-
- print '';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
- print '";
- print " \n";
-
- $somethingshown=1;
}
- print "
";
- print ' ';
show_list_sending_receive('commande',$commande->id);
}
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 44c87c56cc8..a50074ff937 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -210,7 +210,7 @@ if ($_GET["action"] == 'create')
$expe = new Expedition($db);
- print_titre($langs->trans("CreateASending"));
+ print_fiche_titre($langs->trans("CreateASending"));
if (! $origin)
{
$mesg=''.$langs->trans("ErrorBadParameters").'
';
@@ -295,9 +295,8 @@ if ($_GET["action"] == 'create')
{
print ''.$langs->trans("NotePrivate").': '.nl2br($object->note)." ";
}
- print "
";
-
- print '';
-
-
- print '';
+ print ' ';
// Delivery method
print "".$langs->trans("DeliveryMethod")." ";
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 47813d4a029..061f6d1bfa2 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -485,10 +485,10 @@ class Facture extends CommonObject
/**
- * \brief Recupére l'objet facture et ses lignes de factures
- * \param rowid id de la facture a récupérer
+ * \brief Get object and lines from database
+ * \param rowid id of object to load
* \param ref Ref of invoice
- * \return int >0 si ok, <0 si ko
+ * \return int >0 if OK, <0 if KO
*/
function fetch($rowid,$ref='')
{
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index 21f012afa81..c10ee5deb65 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -62,6 +62,7 @@ FeaturesSupported=Features supported
Width=Width
Height=Height
Weight=Weight
+Depth=Depth
TotalWeight=Total weight
WeightUnitton=tonnes
WeightUnitkg=kg
@@ -73,9 +74,6 @@ VolumeUnitm3=m3
VolumeUnitdm3=dm3
VolumeUnitcm3=cm3
VolumeUnitmm3=mm3
-Height=height
-Width=width
-Depth=depth
Size=size
SizeUnitm=m
SizeUnitdm=dm
diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang
index ce7aef31ad3..327b2d7d6cc 100644
--- a/htdocs/langs/en_US/sendings.lang
+++ b/htdocs/langs/en_US/sendings.lang
@@ -41,6 +41,7 @@ ConfirmCancelSending=Are you sure you want to cancel this sending ?
GenericTransport=Generic transport
Enlevement=Gotten by customer
DocumentModelSimple=Simple document model
-
+WarningNoQtyLeftToSend=Warning, no products waiting to be shipped.
+
# NumRef
NumRefModelJade=Return a reference number with format BLYY00001, ... where YY is year. Number at end is never reset to zero.
diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang
index f7c4fd78356..fc5badf74ee 100644
--- a/htdocs/langs/fr_FR/other.lang
+++ b/htdocs/langs/fr_FR/other.lang
@@ -62,6 +62,7 @@ FeaturesSupported=Fonctionnalit
Width=Largeur
Height=Hauteur
Weight=Poids
+Depth=Profondeur
TotalWeight=Poids total
WeightUnitton=tonnes
WeightUnitkg=kg
@@ -73,9 +74,6 @@ VolumeUnitm3=m3
VolumeUnitdm3=dm3
VolumeUnitcm3=cm3
VolumeUnitmm3=mm3
-Height=hauteur
-Width=largeur
-Depth=profondeur
Size=taille
SizeUnitm=m
SizeUnitdm=dm
diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang
index 2b03d9f53b1..dee96ca13b9 100644
--- a/htdocs/langs/fr_FR/sendings.lang
+++ b/htdocs/langs/fr_FR/sendings.lang
@@ -41,6 +41,7 @@ ConfirmCancelSending=Etes-vous s
GenericTransport=Transporteur générique
Enlevement=Enlèvement sur place par le client
DocumentModelSimple=Modèle simple
+WarningNoQtyLeftToSend=Alerte, aucun produit en attente de livraison.
# NumRef
NumRefModelJade=Renvoie un numéro de référence sous la forme numérique BLYY00001, ... où YY représente l'année. Le numéro d'incrément qui suit l'année n'est PAS remis à zéro en début d'année.
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index 1fa901e47c6..88961283f9c 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -1142,7 +1142,7 @@ if ($_GET["action"] == '')
print ''.$langs->trans("Modify").' ';
if ($product->no_button_copy <> 1)
- print ''.$langs->trans("CreateCopy").' ';
+ print ''.$langs->trans("ToClone").' ';
}
/*