diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index d861f535bc4..e9f55fb68f9 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -206,8 +206,9 @@ if ($_GET["action"] == 'setmod')
/*
- * Affiche page
+ * Viewe
*/
+
$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/";
$html=new Form($db);
@@ -242,107 +243,11 @@ if ($conf->global->MAIN_SUBMODULE_LIVRAISON)
dolibarr_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
-// M�thode de livraison
-$mods=array();
-$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."expedition_methode WHERE statut = 1";
-$resql = $db->query($sql);
-if ($resql)
-{
- $i = 0;
- $num = $db->num_rows($resql);
- while ($i < $num)
- {
- $obj = $db->fetch_object($resql);
- $mods[$i]=$obj->rowid;
- $i++;
- }
-}
-
-print '
';
-print '';
-print '| '.$langs->trans("Name").' | '.$langs->trans("Description").' | ';
-print ''.$langs->trans("Action").' | ';
-print ''.$langs->trans("Default").' | ';
-print ''.$langs->trans("Infos").' | ';
-print "
\n";
-
-if(is_dir($dir))
-{
- $handle=opendir($dir);
- $var=true;
-
- while (($file = readdir($handle))!==false)
- {
- if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,19) == 'methode_expedition_')
- {
- $name = substr($file, 19, strlen($file) - 31);
- $classname = substr($file, 0, strlen($file) - 12);
-
- require_once($dir.$file);
-
- $module = new $classname();
-
- $var=!$var;
- print "| ";
- print $module->name;
- print " | \n";
-
- print $module->description;
-
- print ' | ';
-
- if (in_array($module->id, $mods))
- {
- if ($conf->global->EXPEDITION_ADDON != $name)
- {
- print 'id.'">';
- print img_tick($langs->trans("Disable"));
- print '';
- }
- else
- {
- print img_tick($langs->trans("Activated"));
- }
-
- }
- else
- {
- print 'id.'">'.$langs->trans("Activate").'';
- }
-
- print ' | ';
-
- // Default
- print '';
- if ($conf->global->EXPEDITION_ADDON == $name)
- {
- print img_tick($langs->trans("Activate"));
- }
- else
- {
- print 'id.'">'.$langs->trans("Default").'';
- }
- print ' | ';
-
- // Info
- print ' | ';
-
- print '
';
- }
- }
- closedir($handle);
-}
-else
-{
- print "| ERROR: $dir is not a directory ! |
\n";
-}
-print '
';
/*
* Modeles de documents
*/
-print '
';
print_titre($langs->trans("SendingsReceiptModel"));
// Defini tableau def de modele invoice
diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php
index 613a2d7407a..8c29c57e070 100644
--- a/htdocs/expedition/expedition.class.php
+++ b/htdocs/expedition/expedition.class.php
@@ -31,8 +31,8 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande
/**
- \class Expedition
- \brief Classe de gestion des expeditions
+ * \class Expedition
+ * \brief Classe de gestion des expeditions
*/
class Expedition extends CommonObject
{
@@ -80,21 +80,23 @@ class Expedition extends CommonObject
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
$error = 0;
- /* On positionne en mode brouillon l'expedition */
- $this->brouillon = 1;
+ // Clean parameters
+ $this->brouillon = 1;
+ $this->tracking_number = sanitizeFileName($this->tracking_number);
+
$this->user = $user;
- $this->expedition_method = sanitizeFileName($this->expedition_method);
- $this->tracking_number = sanitizeFileName($this->tracking_number);
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition,";
$sql.= " fk_soc, fk_expedition_methode, tracking_number, weight, size, width, height, weight_units, size_units";
$sql.= ")";
- $sql.= " VALUES ('(PROV)', now(), $user->id, ".$this->db->idate($this->date_expedition);
- $sql.= ", ".$this->socid.",'". $this->expedition_method_id."','". $this->tracking_number."',".$this->weight.",".$this->sizeS.",".$this->sizeW.",".$this->sizeH.",".$this->weight_units.",".$this->size_units;
+ $sql.= " VALUES ('(PROV)', ".$this->db->idate(gmmktime()).", ".$user->id.", ".$this->db->idate($this->date_expedition).",";
+ $sql.= " ".$this->socid.",";
+ $sql.= " ".($this->expedition_method_id>0?$this->expedition_method_id:"null").",";
+ $sql.= " '". $this->tracking_number."',".$this->weight.",".$this->sizeS.",".$this->sizeW.",".$this->sizeH.",".$this->weight_units.",".$this->size_units;
$sql.= ")";
$resql=$this->db->query($sql);
@@ -110,7 +112,7 @@ class Expedition extends CommonObject
{
if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0)
{
- $error++;
+ $error++;
}
}
@@ -118,32 +120,32 @@ class Expedition extends CommonObject
{
if ($conf->commande->enabled)
{
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')';
- if (!$this->db->query($sql))
- {
- $error++;
- }
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id;
- if (! $this->db->query($sql))
- {
- $error++;
- }
+ $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')';
+ if (!$this->db->query($sql))
+ {
+ $error++;
+ }
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id;
+ if (! $this->db->query($sql))
+ {
+ $error++;
+ }
}
else
{
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')';
- if (!$this->db->query($sql))
- {
- $error++;
- }
-
- //Todo: definir un statut
- $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id;
- if (! $this->db->query($sql))
- {
- $error++;
- }
+ $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')';
+ if (!$this->db->query($sql))
+ {
+ $error++;
+ }
+
+ //Todo: definir un statut
+ $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id;
+ if (! $this->db->query($sql))
+ {
+ $error++;
+ }
}
}
@@ -777,29 +779,8 @@ class Expedition extends CommonObject
}
}
- /*
- Get id of default expedition method
- */
- function GetIdOfDefault()
- {
- global $conf;
-
- $sql = "SELECT em.rowid";
- $sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em";
- $sql.= " WHERE em.code = '".strtoupper($conf->global->EXPEDITION_ADDON)."'";
-
- $resql = $this->db->query($sql);
- if ($resql)
- {
- if ($obj = $this->db->fetch_object($resql))
- {
- $this->default_method_id = $obj->rowid;
- }
- }
- }
-
- /*
- Get tracking url status
+ /**
+ * Get tracking url status
*/
function GetUrlTrackingStatus()
{
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 4832d053e1b..198d42a1489 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -316,8 +316,7 @@ if ($_GET["action"] == 'create')
print "| ".$langs->trans("DeliveryMethod")." | ";
print '';
$expe->fetch_delivery_methods();
- $expe->GetIdOfDefault();
- $html->select_array("expedition_method_id",$expe->meths,$expe->default_method_id,0,0,0,0,"",1);
+ $html->select_array("expedition_method_id",$expe->meths,'',1,0,0,0,"",1);
print " |
\n";
// Tracking number
@@ -524,7 +523,8 @@ else
$typeobject = $expedition->origin;
$expedition->fetch_object();
- if (strlen($expedition->tracking_number) && strlen($expedition->expedition_method_id)) {
+ if (strlen($expedition->tracking_number))
+ {
$expedition->GetUrlTrackingStatus();
}
@@ -688,6 +688,15 @@ else
print ''.$expedition->getLibStatut(4)." | \n";
print '';
+ // Sending method
+ print '| '.$langs->trans("SendingMethod").' | ';
+ print '';
+ // Get code using getLabelFromKey
+ $code=$langs->getLabelFromKey($db,$expedition->expedition_method_id,'expedition_methode','rowid','code');
+ print $langs->trans("SendingMethod".strtoupper($code));
+ print ' | ';
+ print '
';
+
// Tracking Number
print '| '.$langs->trans("TrackingNumber").' | ';
print ''.$expedition->tracking_number.' | ';
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index fc2123ed8bf..07b0d72f72d 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -403,13 +403,14 @@ if ($_GET["action"] == 'create')
* Mode creation
* Creation d'une nouvelle fiche d'intervention
*/
+
+ $societe=new Societe($db);
if ($_GET["socid"] > 0)
{
- $societe=new Societe($db);
$societe->fetch($_GET["socid"]);
}
- print_titre($langs->trans("AddIntervention"));
+ print_fiche_titre($langs->trans("AddIntervention"));
if ($mesg) print $mesg.'
';
@@ -429,7 +430,7 @@ if ($_GET["action"] == 'create')
$modFicheinter = new $obj;
$numpr = $modFicheinter->getNextValue($societe,$ficheinter);
- if ($_GET["socid"])
+ if ($_GET["socid"] > 0)
{
print "