Fix: best autonomy of modules
Fix: uniformise fields and code !! not stable !!
This commit is contained in:
parent
64b94af009
commit
f1d67cba3c
@ -2874,7 +2874,6 @@ CREATE TABLE `llx_livraison` (
|
|||||||
`entity` int(11) NOT NULL DEFAULT '1',
|
`entity` int(11) NOT NULL DEFAULT '1',
|
||||||
`ref_client` varchar(30) DEFAULT NULL,
|
`ref_client` varchar(30) DEFAULT NULL,
|
||||||
`fk_soc` int(11) NOT NULL,
|
`fk_soc` int(11) NOT NULL,
|
||||||
`fk_expedition` int(11) DEFAULT NULL,
|
|
||||||
`date_creation` datetime DEFAULT NULL,
|
`date_creation` datetime DEFAULT NULL,
|
||||||
`fk_user_author` int(11) DEFAULT NULL,
|
`fk_user_author` int(11) DEFAULT NULL,
|
||||||
`date_valid` datetime DEFAULT NULL,
|
`date_valid` datetime DEFAULT NULL,
|
||||||
|
|||||||
@ -410,6 +410,11 @@ class CommonObject
|
|||||||
function fetch_object()
|
function fetch_object()
|
||||||
{
|
{
|
||||||
$object = $this->origin;
|
$object = $this->origin;
|
||||||
|
|
||||||
|
// TODO uniformise code
|
||||||
|
if ($object == 'shipping') $object = 'expedition';
|
||||||
|
if ($object == 'delivery') $object = 'livraison';
|
||||||
|
|
||||||
$class = ucfirst($object);
|
$class = ucfirst($object);
|
||||||
$this->$object = new $class($this->db);
|
$this->$object = new $class($this->db);
|
||||||
$this->$object->fetch($this->origin_id);
|
$this->$object->fetch($this->origin_id);
|
||||||
|
|||||||
@ -44,6 +44,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
var $socid;
|
var $socid;
|
||||||
|
var $ref_customer;
|
||||||
var $brouillon;
|
var $brouillon;
|
||||||
var $entrepot_id;
|
var $entrepot_id;
|
||||||
var $modelpdf;
|
var $modelpdf;
|
||||||
@ -52,6 +53,10 @@ class Expedition extends CommonObject
|
|||||||
var $lignes;
|
var $lignes;
|
||||||
var $meths;
|
var $meths;
|
||||||
|
|
||||||
|
var $date_delivery;
|
||||||
|
var $date_creation;
|
||||||
|
var $date_valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialisation
|
* Initialisation
|
||||||
*/
|
*/
|
||||||
@ -90,10 +95,12 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (";
|
||||||
$sql.= "ref";
|
$sql.= "ref";
|
||||||
|
$sql.= ", ref_customer";
|
||||||
$sql.= ", entity";
|
$sql.= ", entity";
|
||||||
$sql.= ", date_creation";
|
$sql.= ", date_creation";
|
||||||
$sql.= ", fk_user_author";
|
$sql.= ", fk_user_author";
|
||||||
$sql.= ", date_expedition";
|
$sql.= ", date_expedition";
|
||||||
|
$sql.= ", date_delivery";
|
||||||
$sql.= ", fk_soc";
|
$sql.= ", fk_soc";
|
||||||
$sql.= ", fk_adresse_livraison";
|
$sql.= ", fk_adresse_livraison";
|
||||||
$sql.= ", fk_expedition_methode";
|
$sql.= ", fk_expedition_methode";
|
||||||
@ -104,13 +111,14 @@ class Expedition extends CommonObject
|
|||||||
$sql.= ", height";
|
$sql.= ", height";
|
||||||
$sql.= ", weight_units";
|
$sql.= ", weight_units";
|
||||||
$sql.= ", size_units";
|
$sql.= ", size_units";
|
||||||
$sql.= ")";
|
$sql.= ") VALUES (";
|
||||||
$sql.= " VALUES (";
|
|
||||||
$sql.= "'(PROV)'";
|
$sql.= "'(PROV)'";
|
||||||
|
$sql.= ", '".$this->ref_customer."'";
|
||||||
$sql.= ", ".$conf->entity;
|
$sql.= ", ".$conf->entity;
|
||||||
$sql.= ", ".$this->db->idate(gmmktime());
|
$sql.= ", ".$this->db->idate(gmmktime());
|
||||||
$sql.= ", ".$user->id;
|
$sql.= ", ".$user->id;
|
||||||
$sql.= ", ".$this->db->idate($this->date_expedition);
|
$sql.= ", ".$this->db->idate($this->date_expedition);
|
||||||
|
$sql.= ", ".$this->db->idate($this->date_delivery);
|
||||||
$sql.= ", ".$this->socid;
|
$sql.= ", ".$this->socid;
|
||||||
$sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null");
|
$sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null");
|
||||||
$sql.= ", ".($this->expedition_method_id>0?$this->expedition_method_id:"null");
|
$sql.= ", ".($this->expedition_method_id>0?$this->expedition_method_id:"null");
|
||||||
@ -152,15 +160,8 @@ class Expedition extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->commande->enabled)
|
// TODO uniformiser les statuts
|
||||||
{
|
|
||||||
$ret = $this->setStatut(2,$this->origin_id,$this->origin);
|
$ret = $this->setStatut(2,$this->origin_id,$this->origin);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO definir un statut
|
|
||||||
$ret = $this->setStatut(9,$this->origin_id,$this->origin);
|
|
||||||
}
|
|
||||||
if (! $ret)
|
if (! $ret)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -205,9 +206,18 @@ class Expedition extends CommonObject
|
|||||||
{
|
{
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (";
|
||||||
$sql .= " VALUES (".$this->id.", ".($entrepot_id?$entrepot_id:'null').", ".$origin_line_id.", ".$qty.")";
|
$sql.= "fk_expedition";
|
||||||
//print 'x'.$sql;
|
$sql.= ", fk_entrepot";
|
||||||
|
$sql.= ", fk_origin_line";
|
||||||
|
$sql.= ", qty";
|
||||||
|
$sql.= ") VALUES (";
|
||||||
|
$sql.= $this->id;
|
||||||
|
$sql.= ", ".($entrepot_id?$entrepot_id:'null');
|
||||||
|
$sql.= ", ".$origin_line_id;
|
||||||
|
$sql.= ", ".$qty;
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
if (! $this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -225,26 +235,13 @@ class Expedition extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT e.rowid, e.fk_soc as socid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut";
|
$sql = "SELECT e.rowid, e.fk_soc as socid, e.date_creation, e.ref, e.ref_customer, e.fk_user_author, e.fk_statut";
|
||||||
$sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
|
$sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
|
||||||
$sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_adresse_livraison";
|
$sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_adresse_livraison, e.date_delivery";
|
||||||
$sql.= ", e.fk_expedition_methode, e.tracking_number";
|
$sql.= ", e.fk_expedition_methode, e.tracking_number";
|
||||||
$sql.= ", el.fk_source as origin_id";
|
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
|
||||||
$sql.= ", ori.ref_client";
|
|
||||||
if ($conf->livraison_bon->enabled) $sql.=", l.rowid as livraison_id";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->element."'";
|
||||||
if ($conf->commande->enabled)
|
|
||||||
{
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as ori ON el.fk_source = ori.rowid";
|
|
||||||
$sql.= " AND el.sourcetype = 'commande'";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as ori ON el.fk_source = ori.rowid";
|
|
||||||
$sql.= " AND el.sourcetype = 'propal'";
|
|
||||||
}
|
|
||||||
if ($conf->livraison_bon->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition";
|
|
||||||
$sql.= " WHERE e.rowid = ".$id;
|
$sql.= " WHERE e.rowid = ".$id;
|
||||||
|
|
||||||
dol_syslog("Expedition::fetch sql=".$sql);
|
dol_syslog("Expedition::fetch sql=".$sql);
|
||||||
@ -258,17 +255,19 @@ class Expedition extends CommonObject
|
|||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->ref = $obj->ref;
|
$this->ref = $obj->ref;
|
||||||
$this->socid = $obj->socid;
|
$this->socid = $obj->socid;
|
||||||
$this->ref_client = $obj->ref_client;
|
$this->ref_customer = $obj->ref_customer;
|
||||||
$this->statut = $obj->fk_statut;
|
$this->statut = $obj->fk_statut;
|
||||||
$this->origin_id = $obj->origin_id;
|
|
||||||
$this->livraison_id = $obj->livraison_id;
|
|
||||||
$this->user_author_id = $obj->fk_user_author;
|
$this->user_author_id = $obj->fk_user_author;
|
||||||
$this->date = $this->db->jdate($obj->date_expedition);
|
$this->date = $this->db->jdate($obj->date_expedition); // TODO obsolete
|
||||||
|
$this->date_shipping = $this->db->jdate($obj->date_expedition);
|
||||||
|
$this->date_delivery = $this->db->jdate($obj->date_delivery);
|
||||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison; // TODO obsolete
|
$this->adresse_livraison_id = $obj->fk_adresse_livraison; // TODO obsolete
|
||||||
$this->fk_delivery_address = $obj->fk_adresse_livraison;
|
$this->fk_delivery_address = $obj->fk_adresse_livraison;
|
||||||
$this->modelpdf = $obj->model_pdf;
|
$this->modelpdf = $obj->model_pdf;
|
||||||
$this->expedition_method_id = $obj->fk_expedition_methode;
|
$this->expedition_method_id = $obj->fk_expedition_methode;
|
||||||
$this->tracking_number = $obj->tracking_number;
|
$this->tracking_number = $obj->tracking_number;
|
||||||
|
$this->origin = $obj->origin;
|
||||||
|
$this->origin_id = $obj->origin_id;
|
||||||
|
|
||||||
$this->trueWeight = $obj->weight;
|
$this->trueWeight = $obj->weight;
|
||||||
$this->weight_units = $obj->weight_units;
|
$this->weight_units = $obj->weight_units;
|
||||||
@ -284,15 +283,6 @@ class Expedition extends CommonObject
|
|||||||
$this->trueSize = $obj->size."x".$obj->width."x".$obj->height;
|
$this->trueSize = $obj->size."x".$obj->width."x".$obj->height;
|
||||||
$this->size_units = $obj->size_units;
|
$this->size_units = $obj->size_units;
|
||||||
|
|
||||||
if ($conf->commande->enabled)
|
|
||||||
{
|
|
||||||
$this->origin = "commande";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->origin = "propal";
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
if ($this->statut == 0) $this->brouillon = 1;
|
if ($this->statut == 0) $this->brouillon = 1;
|
||||||
@ -303,7 +293,7 @@ class Expedition extends CommonObject
|
|||||||
$this->pdf_filename = $file;
|
$this->pdf_filename = $file;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes
|
* Lines
|
||||||
*/
|
*/
|
||||||
$result=$this->fetch_lines();
|
$result=$this->fetch_lines();
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
@ -359,8 +349,8 @@ class Expedition extends CommonObject
|
|||||||
$num = "EXP".$this->id;
|
$num = "EXP".$this->id;
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
|
||||||
$sql.= " SET ref='".$num."'";
|
$sql.= " ref='".$num."'";
|
||||||
$sql.= ", fk_statut = 1";
|
$sql.= ", fk_statut = 1";
|
||||||
$sql.= ", date_valid = ".$this->db->idate(mktime());
|
$sql.= ", date_valid = ".$this->db->idate(mktime());
|
||||||
$sql.= ", fk_user_valid = ".$user->id;
|
$sql.= ", fk_user_valid = ".$user->id;
|
||||||
@ -493,15 +483,15 @@ class Expedition extends CommonObject
|
|||||||
{
|
{
|
||||||
// Expedition validee
|
// Expedition validee
|
||||||
include_once(DOL_DOCUMENT_ROOT."/livraison/livraison.class.php");
|
include_once(DOL_DOCUMENT_ROOT."/livraison/livraison.class.php");
|
||||||
$livraison = new Livraison($this->db);
|
$delivery = new Livraison($this->db);
|
||||||
$result=$livraison->create_from_sending($user, $this->id);
|
$result=$delivery->create_from_sending($user, $this->id);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$livraison->error;
|
$this->error=$delivery->error;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -517,29 +507,30 @@ class Expedition extends CommonObject
|
|||||||
function addline( $entrepot_id, $id, $qty )
|
function addline( $entrepot_id, $id, $qty )
|
||||||
{
|
{
|
||||||
$num = sizeof($this->lignes);
|
$num = sizeof($this->lignes);
|
||||||
$ligne = new ExpeditionLigne($this->db);
|
$line = new ExpeditionLigne($this->db);
|
||||||
|
|
||||||
$ligne->entrepot_id = $entrepot_id;
|
$line->entrepot_id = $entrepot_id;
|
||||||
$ligne->origin_line_id = $id;
|
$line->origin_line_id = $id;
|
||||||
$ligne->qty = $qty;
|
$line->qty = $qty;
|
||||||
|
|
||||||
$this->lignes[$num] = $ligne;
|
$this->lignes[$num] = $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function delete_line($idligne)
|
function delete_line($id)
|
||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
|
||||||
$sql.= " WHERE rowid = ".$idligne;
|
$sql.= " WHERE rowid = ".$id;
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -647,25 +638,25 @@ class Expedition extends CommonObject
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$ligne = new ExpeditionLigne($this->db);
|
$line = new ExpeditionLigne($this->db);
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$ligne->origin_line_id = $obj->fk_origin_line;
|
$line->origin_line_id = $obj->fk_origin_line;
|
||||||
$ligne->entrepot_id = $obj->fk_entrepot;
|
$line->entrepot_id = $obj->fk_entrepot;
|
||||||
$ligne->fk_product = $obj->fk_product;
|
$line->fk_product = $obj->fk_product;
|
||||||
$ligne->fk_product_type= $obj->fk_product_type;
|
$line->fk_product_type = $obj->fk_product_type;
|
||||||
$ligne->ref = $obj->ref;
|
$line->ref = $obj->ref;
|
||||||
$ligne->label = $obj->label; // deprecated
|
$line->label = $obj->label;
|
||||||
$ligne->libelle = $obj->label;
|
$line->libelle = $obj->label; // deprecated
|
||||||
$ligne->description = $obj->description;
|
$line->description = $obj->description;
|
||||||
$ligne->qty_asked = $obj->qty_asked;
|
$line->qty_asked = $obj->qty_asked;
|
||||||
$ligne->qty_shipped = $obj->qty_shipped;
|
$line->qty_shipped = $obj->qty_shipped;
|
||||||
$ligne->weight = $obj->weight;
|
$line->weight = $obj->weight;
|
||||||
$ligne->weight_units = $obj->weight_units;
|
$line->weight_units = $obj->weight_units;
|
||||||
$ligne->volume = $obj->volume;
|
$line->volume = $obj->volume;
|
||||||
$ligne->volume_units = $obj->volume_units;
|
$line->volume_units = $obj->volume_units;
|
||||||
|
|
||||||
$this->lignes[$i] = $ligne;
|
$this->lignes[$i] = $line;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|||||||
@ -606,20 +606,11 @@ else
|
|||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($expedition->socid);
|
$soc->fetch($expedition->socid);
|
||||||
|
|
||||||
$h=0;
|
// delivery link
|
||||||
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id;
|
$expedition->load_object_linked($expedition->id,$expedition->element,-1,-1);
|
||||||
$head[$h][1] = $langs->trans("SendingCard");
|
|
||||||
$hselected = $h;
|
|
||||||
$h++;
|
|
||||||
|
|
||||||
if ($conf->livraison_bon->enabled && $expedition->livraison_id)
|
$head=shipping_prepare_head($expedition);
|
||||||
{
|
dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending');
|
||||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$expedition->livraison_id;
|
|
||||||
$head[$h][1] = $langs->trans("DeliveryCard");
|
|
||||||
$h++;
|
|
||||||
}
|
|
||||||
|
|
||||||
dol_fiche_head($head, $hselected, $langs->trans("Sending"), 0, 'sending');
|
|
||||||
|
|
||||||
if ($mesg) print $mesg;
|
if ($mesg) print $mesg;
|
||||||
|
|
||||||
@ -705,7 +696,7 @@ else
|
|||||||
|
|
||||||
// Ref customer
|
// Ref customer
|
||||||
print '<tr><td>'.$langs->trans("RefCustomer").'</td>';
|
print '<tr><td>'.$langs->trans("RefCustomer").'</td>';
|
||||||
print '<td colspan="3">'.$expedition->ref_client."</a></td>\n";
|
print '<td colspan="3">'.$expedition->ref_customer."</a></td>\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
@ -914,7 +905,7 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && !$expedition->livraison_id)
|
if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && empty($expedition->linked_object))
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
|
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
|
||||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -20,18 +20,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/includes/modules/livraison/mod_livraison_jade.php
|
* \file htdocs/includes/modules/livraison/mod_livraison_jade.php
|
||||||
\ingroup livraison
|
* \ingroup delivery
|
||||||
\brief Fichier contenant la classe du modele de numerotation de reference de bon de livraison Jade
|
* \brief Fichier contenant la classe du modele de numerotation de reference de bon de livraison Jade
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/livraison/modules_livraison.php");
|
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/livraison/modules_livraison.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class mod_livraison_jade
|
* \class mod_livraison_jade
|
||||||
\brief Classe du modele de numerotation de reference de bon de livraison Jade
|
* \brief Classe du modele de numerotation de reference de bon de livraison Jade
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
||||||
@ -41,7 +41,8 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
|||||||
var $nom = "Jade";
|
var $nom = "Jade";
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de numerotation
|
/**
|
||||||
|
* \brief Renvoi la description du modele de numerotation
|
||||||
* \return string Texte descripif
|
* \return string Texte descripif
|
||||||
*/
|
*/
|
||||||
function info()
|
function info()
|
||||||
@ -50,7 +51,8 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
|||||||
return $langs->trans("NumRefModelJade");
|
return $langs->trans("NumRefModelJade");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Renvoi un exemple de numerotation
|
/**
|
||||||
|
* \brief Renvoi un exemple de numerotation
|
||||||
* \return string Example
|
* \return string Example
|
||||||
*/
|
*/
|
||||||
function getExample()
|
function getExample()
|
||||||
@ -58,12 +60,13 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
|||||||
return "BL0600001";
|
return "BL0600001";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Return next value
|
/**
|
||||||
|
* \brief Return next value
|
||||||
* \param objsoc Object third party
|
* \param objsoc Object third party
|
||||||
* \param livraison Object delivery
|
* \param delivery Object delivery
|
||||||
* \return string Value if OK, 0 if KO
|
* \return string Value if OK, 0 if KO
|
||||||
*/
|
*/
|
||||||
function getNextValue($objsoc=0,$livraison='')
|
function getNextValue($objsoc=0,$delivery='')
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
@ -103,8 +106,8 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
|||||||
{
|
{
|
||||||
$max=0;
|
$max=0;
|
||||||
}
|
}
|
||||||
//$date=time();
|
|
||||||
$date=$livraison->date_livraison;
|
$date = $delivery->date_delivery;
|
||||||
$yy = strftime("%y",$date);
|
$yy = strftime("%y",$date);
|
||||||
$num = sprintf("%05s",$max+1);
|
$num = sprintf("%05s",$max+1);
|
||||||
|
|
||||||
@ -112,7 +115,8 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoie la reference de commande suivante non utilisee
|
/**
|
||||||
|
* \brief Renvoie la reference de commande suivante non utilisee
|
||||||
* \param objsoc Objet societe
|
* \param objsoc Objet societe
|
||||||
* \param livraison Objet livraison
|
* \param livraison Objet livraison
|
||||||
* \return string Texte descripif
|
* \return string Texte descripif
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
-- Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
-- Copyright (C) 2008-2009 Regis Houssin <regis@dolibarr.fr>
|
-- Copyright (C) 2008-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
--
|
--
|
||||||
-- 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
|
||||||
@ -25,13 +25,15 @@ create table llx_expedition
|
|||||||
tms timestamp,
|
tms timestamp,
|
||||||
ref varchar(30) NOT NULL,
|
ref varchar(30) NOT NULL,
|
||||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
|
ref_customer varchar(30), -- customer number
|
||||||
fk_soc integer NOT NULL,
|
fk_soc integer NOT NULL,
|
||||||
|
|
||||||
date_creation datetime, -- date de creation
|
date_creation datetime, -- date de creation
|
||||||
fk_user_author integer, -- createur
|
fk_user_author integer, -- createur
|
||||||
date_valid datetime, -- date de validation
|
date_valid datetime, -- date de validation
|
||||||
fk_user_valid integer, -- valideur
|
fk_user_valid integer, -- valideur
|
||||||
date_expedition date, -- date de lexpedition
|
date_expedition date, -- shipping date
|
||||||
|
date_delivery date DEFAULT NULL, -- delivery date
|
||||||
fk_adresse_livraison integer DEFAULT NULL, -- adresse de livraison
|
fk_adresse_livraison integer DEFAULT NULL, -- adresse de livraison
|
||||||
fk_expedition_methode integer,
|
fk_expedition_methode integer,
|
||||||
tracking_number varchar(50),
|
tracking_number varchar(50),
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
-- Copyright (C) 2008-2009 Regis Houssin <regis@dolibarr.fr>
|
-- Copyright (C) 2008-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
--
|
--
|
||||||
-- 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
|
||||||
@ -25,18 +25,17 @@ create table llx_livraison
|
|||||||
tms timestamp,
|
tms timestamp,
|
||||||
ref varchar(30) NOT NULL, -- delivery number
|
ref varchar(30) NOT NULL, -- delivery number
|
||||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
ref_client varchar(30), -- customer number
|
ref_customer varchar(30), -- customer number
|
||||||
fk_soc integer NOT NULL,
|
fk_soc integer NOT NULL,
|
||||||
fk_expedition integer, -- expedition auquel est rattache le bon de livraison
|
|
||||||
|
|
||||||
date_creation datetime, -- date de creation
|
date_creation datetime, -- date de creation
|
||||||
fk_user_author integer, -- createur du bon de livraison
|
fk_user_author integer, -- createur du bon de livraison
|
||||||
date_valid datetime, -- date de validation
|
date_valid datetime, -- date de validation
|
||||||
fk_user_valid integer, -- valideur du bon de livraison
|
fk_user_valid integer, -- valideur du bon de livraison
|
||||||
date_livraison date default NULL, -- date de livraison
|
date_delivery date DEFAULT NULL, -- delivery date
|
||||||
fk_adresse_livraison integer, -- adresse de livraison
|
fk_adresse_livraison integer, -- adresse de livraison
|
||||||
fk_statut smallint default 0,
|
fk_statut smallint DEFAULT 0,
|
||||||
total_ht double(24,8) default 0,
|
total_ht double(24,8) DEFAULT 0,
|
||||||
note text,
|
note text,
|
||||||
note_public text,
|
note_public text,
|
||||||
model_pdf varchar(50)
|
model_pdf varchar(50)
|
||||||
|
|||||||
@ -54,6 +54,6 @@ create table llx_propal
|
|||||||
note text,
|
note text,
|
||||||
note_public text,
|
note_public text,
|
||||||
model_pdf varchar(50),
|
model_pdf varchar(50),
|
||||||
date_livraison date default NULL,
|
date_livraison date DEFAULT NULL, -- delivery date
|
||||||
fk_adresse_livraison integer -- adresse de livraison
|
fk_adresse_livraison integer -- adresse de livraison
|
||||||
)type=innodb;
|
)type=innodb;
|
||||||
|
|||||||
@ -273,6 +273,12 @@ if (isset($_POST['action']) && preg_match('/upgrade/i',$_POST["action"]))
|
|||||||
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
|
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
|
||||||
{
|
{
|
||||||
migrate_project_task_time($db,$langs,$conf);
|
migrate_project_task_time($db,$langs,$conf);
|
||||||
|
|
||||||
|
migrate_customerorder_shipping($db,$langs,$conf);
|
||||||
|
|
||||||
|
migrate_shipping_delivery($db,$langs,$conf);
|
||||||
|
|
||||||
|
migrate_shipping_delivery2($db,$langs,$conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On commit dans tous les cas.
|
// On commit dans tous les cas.
|
||||||
@ -2829,6 +2835,293 @@ function migrate_project_task_time($db,$langs,$conf)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Migrate order ref_customer and date_delivery fields to llx_expedition
|
||||||
|
*/
|
||||||
|
function migrate_customerorder_shipping($db,$langs,$conf)
|
||||||
|
{
|
||||||
|
print '<tr><td colspan="4">';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
print '<b>'.$langs->trans('MigrationCustomerOrderShipping')."</b><br>\n";
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$result1 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","ref_customer");
|
||||||
|
$result2 = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","date_delivery");
|
||||||
|
$obj1 = $db->fetch_object($result1);
|
||||||
|
$obj2 = $db->fetch_object($result2);
|
||||||
|
if (!$obj1 && !$obj2)
|
||||||
|
{
|
||||||
|
dolibarr_install_syslog("upgrade2::migrate_customerorder_shipping");
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN ref_customer varchar(30) AFTER entity";
|
||||||
|
$sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date_expedition";
|
||||||
|
|
||||||
|
if ($db->query($sqlAdd1) && $db->query($sqlAdd2))
|
||||||
|
{
|
||||||
|
$sqlSelect = "SELECT e.rowid as shipping_id, c.ref_client, c.date_livraison";
|
||||||
|
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||||
|
$sqlSelect.= ", ".MAIN_DB_PREFIX."element_element as el";
|
||||||
|
$sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = el.fk_source AND el.sourcetype = 'commande'";
|
||||||
|
$sqlSelect.= " WHERE e.rowid = el.fk_target";
|
||||||
|
$sqlSelect.= " AND el.targettype = 'shipping'";
|
||||||
|
|
||||||
|
$resql = $db->query($sqlSelect);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
|
||||||
|
$sqlUpdate.= " ref_customer = '".$obj->ref_client."'";
|
||||||
|
$sqlUpdate.= ", date_delivery = '".($obj->date_livraison?$obj->date_livraison:'null')."'";
|
||||||
|
$sqlUpdate.= " WHERE rowid = ".$obj->shipping_id;
|
||||||
|
|
||||||
|
$result=$db->query($sqlUpdate);
|
||||||
|
if (! $result)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
print ". ";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error == 0)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Migrate fk_expedition to llx_element_element
|
||||||
|
*/
|
||||||
|
function migrate_shipping_delivery($db,$langs,$conf)
|
||||||
|
{
|
||||||
|
print '<tr><td colspan="4">';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
print '<b>'.$langs->trans('MigrationShippingDelivery')."</b><br>\n";
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$result = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","fk_expedition");
|
||||||
|
$obj = $db->fetch_object($result);
|
||||||
|
if ($obj)
|
||||||
|
{
|
||||||
|
dolibarr_install_syslog("upgrade2::migrate_shipping_delivery");
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$sqlSelect = "SELECT rowid, fk_expedition";
|
||||||
|
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison";
|
||||||
|
|
||||||
|
$resql = $db->query($sqlSelect);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
$sqlInsert = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
|
||||||
|
$sqlInsert.= "fk_source";
|
||||||
|
$sqlInsert.= ", sourcetype";
|
||||||
|
$sqlInsert.= ", fk_target";
|
||||||
|
$sqlInsert.= ", targettype";
|
||||||
|
$sqlInsert.= ") VALUES (";
|
||||||
|
$sqlInsert.= $obj->fk_expedition;
|
||||||
|
$sqlInsert.= ", 'shipping'";
|
||||||
|
$sqlInsert.= ", ".$obj->rowid;
|
||||||
|
$sqlInsert.= ", 'delivery'";
|
||||||
|
$sqlInsert.= ")";
|
||||||
|
|
||||||
|
$result=$db->query($sqlInsert);
|
||||||
|
if (! $result)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
print ". ";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error == 0)
|
||||||
|
{
|
||||||
|
$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."livraison DROP COLUMN fk_expedition";
|
||||||
|
if ($db->query($sqlDrop))
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Migrate shipping ref_customer and date_delivery fields to llx_livraison
|
||||||
|
*/
|
||||||
|
function migrate_shipping_delivery2($db,$langs,$conf)
|
||||||
|
{
|
||||||
|
print '<tr><td colspan="4">';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
print '<b>'.$langs->trans('MigrationShippingDelivery2')."</b><br>\n";
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
|
$result1 = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","ref_customer");
|
||||||
|
$result2 = $db->DDLDescTable(MAIN_DB_PREFIX."livraison","date_delivery");
|
||||||
|
$obj1 = $db->fetch_object($result1);
|
||||||
|
$obj2 = $db->fetch_object($result2);
|
||||||
|
if (!$obj1 && !$obj2)
|
||||||
|
{
|
||||||
|
dolibarr_install_syslog("upgrade2::migrate_shipping_delivery2");
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$sqlAdd1 = "ALTER TABLE ".MAIN_DB_PREFIX."livraison CHANGE ref_client ref_customer varchar(30)";
|
||||||
|
$sqlAdd2 = "ALTER TABLE ".MAIN_DB_PREFIX."livraison CHANGE date_livraison date_delivery date DEFAULT NULL";
|
||||||
|
|
||||||
|
if ($db->query($sqlAdd1) && $db->query($sqlAdd2))
|
||||||
|
{
|
||||||
|
$sqlSelect = "SELECT l.rowid as delivery_id, e.ref_customer, e.date_delivery";
|
||||||
|
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."livraison as l";
|
||||||
|
$sqlSelect.= ", ".MAIN_DB_PREFIX."element_element as el";
|
||||||
|
$sqlSelect.= " LEFT JOIN ".MAIN_DB_PREFIX."expedition as e ON e.rowid = el.fk_source AND el.sourcetype = 'shipping'";
|
||||||
|
$sqlSelect.= " WHERE l.rowid = el.fk_target";
|
||||||
|
$sqlSelect.= " AND el.targettype = 'delivery'";
|
||||||
|
|
||||||
|
$resql = $db->query($sqlSelect);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
|
||||||
|
$sqlUpdate.= " ref_customer = '".$obj->ref_customer."'";
|
||||||
|
$sqlUpdate.= ", date_delivery = '".($obj->date_delivery?$obj->date_delivery:'null')."'";
|
||||||
|
$sqlUpdate.= " WHERE rowid = ".$obj->delivery_id;
|
||||||
|
|
||||||
|
$result=$db->query($sqlUpdate);
|
||||||
|
if (! $result)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
print ". ";
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error == 0)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans('AlreadyDone')."<br>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Migration directory
|
* Migration directory
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -25,6 +25,92 @@
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||||
|
|
||||||
|
|
||||||
|
function shipping_prepare_head($object)
|
||||||
|
{
|
||||||
|
global $langs, $conf, $user;
|
||||||
|
|
||||||
|
$langs->load("sendings");
|
||||||
|
$langs->load("deliveries");
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
$head = array();
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$object->id;
|
||||||
|
$head[$h][1] = $langs->trans("SendingCard");
|
||||||
|
$head[$h][2] = 'shipping';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && $object->linked_object[0]['linkid'])
|
||||||
|
{
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linked_object[0]['linkid'];
|
||||||
|
$head[$h][1] = $langs->trans("DeliveryCard");
|
||||||
|
$head[$h][2] = 'delivery';
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show more tabs from modules
|
||||||
|
// Entries must be declared in modules descriptor with line
|
||||||
|
// $this->tabs = array('entity:MyModule:@mymodule:/mymodule/mypage.php?id=__ID__');
|
||||||
|
if (is_array($conf->tabs_modules['delivery']))
|
||||||
|
{
|
||||||
|
$i=0;
|
||||||
|
foreach ($conf->tabs_modules['delivery'] as $value)
|
||||||
|
{
|
||||||
|
$values=explode(':',$value);
|
||||||
|
if ($values[2]) $langs->load($values[2]);
|
||||||
|
$head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$commande->id,$values[3]);
|
||||||
|
$head[$h][1] = $langs->trans($values[1]);
|
||||||
|
$head[$h][2] = 'tab'.$values[1];
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $head;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delivery_prepare_head($object)
|
||||||
|
{
|
||||||
|
global $langs, $conf, $user;
|
||||||
|
|
||||||
|
$langs->load("sendings");
|
||||||
|
$langs->load("deliveries");
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
$head = array();
|
||||||
|
|
||||||
|
if ($conf->expedition_bon->enabled && $user->rights->expedition->lire)
|
||||||
|
{
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$object->origin_id;
|
||||||
|
$head[$h][1] = $langs->trans("SendingCard");
|
||||||
|
$head[$h][2] = 'shipping';
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->id;
|
||||||
|
$head[$h][1] = $langs->trans("DeliveryCard");
|
||||||
|
$head[$h][2] = 'delivery';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
// Show more tabs from modules
|
||||||
|
// Entries must be declared in modules descriptor with line
|
||||||
|
// $this->tabs = array('entity:MyModule:@mymodule:/mymodule/mypage.php?id=__ID__');
|
||||||
|
if (is_array($conf->tabs_modules['delivery']))
|
||||||
|
{
|
||||||
|
$i=0;
|
||||||
|
foreach ($conf->tabs_modules['delivery'] as $value)
|
||||||
|
{
|
||||||
|
$values=explode(':',$value);
|
||||||
|
if ($values[2]) $langs->load($values[2]);
|
||||||
|
$head[$h][0] = DOL_URL_ROOT . preg_replace('/__ID__/i',$commande->id,$values[3]);
|
||||||
|
$head[$h][1] = $langs->trans($values[1]);
|
||||||
|
$head[$h][2] = 'tab'.$values[1];
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $head;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List sendings and receive receipts
|
* List sendings and receive receipts
|
||||||
*
|
*
|
||||||
@ -41,13 +127,13 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
|
|||||||
$sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked";
|
$sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked";
|
||||||
$sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
|
$sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
|
||||||
$sql.= ", e.ref as exp_ref, ".$db->pdate("e.date_expedition")." as date_expedition,";
|
$sql.= ", e.ref as exp_ref, ".$db->pdate("e.date_expedition")." as date_expedition,";
|
||||||
if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, ".$db->pdate("l.date_livraison")." as date_delivery, ld.qty as qty_received,";
|
//if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, ".$db->pdate("l.date_delivery")." as date_delivery, ld.qty as qty_received,";
|
||||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX.$origin."det as obj,";
|
$sql.= " ".MAIN_DB_PREFIX.$origin."det as obj,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."expedition as e)";
|
$sql.= " ".MAIN_DB_PREFIX."expedition as e)";
|
||||||
if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line";
|
//if ($conf->livraison_bon->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."livraisondet as ld ON ld.fk_livraison = l.rowid AND obj.rowid = ld.fk_origin_line";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid";
|
||||||
$sql.= " WHERE obj.fk_".$origin." = ".$origin_id;
|
$sql.= " WHERE obj.fk_".$origin." = ".$origin_id;
|
||||||
if ($filter) $sql.=$filter;
|
if ($filter) $sql.=$filter;
|
||||||
|
|||||||
@ -128,7 +128,6 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
|
|||||||
{
|
{
|
||||||
$delivery = new Livraison($db);
|
$delivery = new Livraison($db);
|
||||||
$delivery->fetch($_GET["id"]);
|
$delivery->fetch($_GET["id"]);
|
||||||
$expedition_id = $delivery->expedition_id;
|
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
$result=$delivery->delete();
|
$result=$delivery->delete();
|
||||||
@ -138,7 +137,7 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' &&
|
|||||||
$db->commit();
|
$db->commit();
|
||||||
if ($conf->expedition_bon->enabled)
|
if ($conf->expedition_bon->enabled)
|
||||||
{
|
{
|
||||||
Header("Location: ".DOL_URL_ROOT.'/expedition/fiche.php?id='.$expedition_id);
|
Header("Location: ".DOL_URL_ROOT.'/expedition/fiche.php?id='.$delivery->origin_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -396,7 +395,6 @@ else
|
|||||||
|
|
||||||
if ($delivery->origin_id)
|
if ($delivery->origin_id)
|
||||||
{
|
{
|
||||||
$object = $delivery->origin;
|
|
||||||
$delivery->fetch_object();
|
$delivery->fetch_object();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,20 +403,8 @@ else
|
|||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($delivery->socid);
|
$soc->fetch($delivery->socid);
|
||||||
|
|
||||||
$h=0;
|
$head=delivery_prepare_head($delivery);
|
||||||
if ($conf->expedition_bon->enabled)
|
dol_fiche_head($head, 'delivery', $langs->trans("Sending"), 0, 'sending');
|
||||||
{
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$delivery->expedition_id;
|
|
||||||
$head[$h][1] = $langs->trans("SendingCard");
|
|
||||||
$h++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$delivery->id;
|
|
||||||
$head[$h][1] = $langs->trans("DeliveryCard");
|
|
||||||
$hselected = $h;
|
|
||||||
$h++;
|
|
||||||
|
|
||||||
dol_fiche_head($head, $hselected, $langs->trans("Sending"), 0, 'sending');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la suppression
|
* Confirmation de la suppression
|
||||||
@ -480,7 +466,7 @@ else
|
|||||||
|
|
||||||
// Ref client
|
// Ref client
|
||||||
print '<tr><td>'.$langs->trans("RefCustomer").'</td>';
|
print '<tr><td>'.$langs->trans("RefCustomer").'</td>';
|
||||||
print '<td colspan="3">'.$delivery->ref_client."</a></td>\n";
|
print '<td colspan="3">'.$delivery->ref_customer."</a></td>\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||||
*
|
*
|
||||||
@ -20,10 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/livraison/livraison.class.php
|
* \file htdocs/livraison/livraison.class.php
|
||||||
\ingroup livraison
|
* \ingroup delivery
|
||||||
\brief Fichier de la classe de gestion des bons de livraison
|
* \brief Fichier de la classe de gestion des bons de livraison
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
||||||
@ -34,8 +34,8 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class Livraison
|
* \class Livraison
|
||||||
\brief Classe de gestion des bons de livraison
|
* \brief Classe de gestion des bons de livraison
|
||||||
*/
|
*/
|
||||||
class Livraison extends CommonObject
|
class Livraison extends CommonObject
|
||||||
{
|
{
|
||||||
@ -50,11 +50,11 @@ class Livraison extends CommonObject
|
|||||||
var $origin;
|
var $origin;
|
||||||
var $origin_id;
|
var $origin_id;
|
||||||
var $socid;
|
var $socid;
|
||||||
var $ref_client;
|
var $ref_customer;
|
||||||
|
|
||||||
var $expedition_id;
|
var $expedition_id;
|
||||||
|
|
||||||
var $date_livraison;
|
var $date_delivery;
|
||||||
var $date_creation;
|
var $date_creation;
|
||||||
var $date_valid;
|
var $date_valid;
|
||||||
|
|
||||||
@ -98,21 +98,18 @@ class Livraison extends CommonObject
|
|||||||
$sql.= "ref";
|
$sql.= "ref";
|
||||||
$sql.= ", entity";
|
$sql.= ", entity";
|
||||||
$sql.= ", fk_soc";
|
$sql.= ", fk_soc";
|
||||||
$sql.= ", ref_client";
|
$sql.= ", ref_customer";
|
||||||
$sql.= ", date_creation";
|
$sql.= ", date_creation";
|
||||||
$sql.= ", fk_user_author";
|
$sql.= ", fk_user_author";
|
||||||
$sql.= ", fk_adresse_livraison";
|
$sql.= ", fk_adresse_livraison";
|
||||||
$sql.= ", fk_expedition";
|
$sql.= ") VALUES (";
|
||||||
$sql.= ")";
|
|
||||||
$sql.= " VALUES (";
|
|
||||||
$sql.= "'(PROV)'";
|
$sql.= "'(PROV)'";
|
||||||
$sql.= ", ".$conf->entity;
|
$sql.= ", ".$conf->entity;
|
||||||
$sql.= ", ".$this->socid;
|
$sql.= ", ".$this->socid;
|
||||||
$sql.= ", '".$this->ref_client."'";
|
$sql.= ", '".$this->ref_customer."'";
|
||||||
$sql.= ", ".$this->db->idate(mktime());
|
$sql.= ", ".$this->db->idate(mktime());
|
||||||
$sql.= ", ".$user->id;
|
$sql.= ", ".$user->id;
|
||||||
$sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null");
|
$sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null");
|
||||||
$sql.= ", ".($this->expedition_id ? $this->expedition_id : "null");
|
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog("Livraison::create sql=".$sql, LOG_DEBUG);
|
dol_syslog("Livraison::create sql=".$sql, LOG_DEBUG);
|
||||||
@ -131,7 +128,7 @@ class Livraison extends CommonObject
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if (! $conf->expedition->enabled)
|
if (! $conf->expedition_bon->enabled)
|
||||||
{
|
{
|
||||||
$commande = new Commande($this->db);
|
$commande = new Commande($this->db);
|
||||||
$commande->id = $this->commande_id;
|
$commande->id = $this->commande_id;
|
||||||
@ -163,15 +160,8 @@ class Livraison extends CommonObject
|
|||||||
|
|
||||||
if (! $conf->expedition_bon->enabled)
|
if (! $conf->expedition_bon->enabled)
|
||||||
{
|
{
|
||||||
if ($conf->commande->enabled)
|
// TODO uniformiser les statuts
|
||||||
{
|
|
||||||
$ret = $this->setStatut(2,$this->origin_id,$this->origin);
|
$ret = $this->setStatut(2,$this->origin_id,$this->origin);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO definir un statut
|
|
||||||
$ret = $this->setStatut(9,$this->origin_id,$this->origin);
|
|
||||||
}
|
|
||||||
if (! $ret)
|
if (! $ret)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
@ -248,12 +238,12 @@ class Livraison extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_client, l.fk_user_author,";
|
$sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
|
||||||
$sql.=" l.total_ht, l.fk_statut, l.fk_expedition, l.fk_user_valid, l.note, l.note_public";
|
$sql.=" l.total_ht, l.fk_statut, l.fk_user_valid, l.note, l.note_public";
|
||||||
$sql.= ", l.date_livraison as date_livraison, l.fk_adresse_livraison, l.model_pdf";
|
$sql.= ", l.date_delivery, l.fk_adresse_livraison, l.model_pdf";
|
||||||
$sql.= ", el.fk_source as origin_id";
|
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."livraison as l";
|
$sql.= " FROM ".MAIN_DB_PREFIX."livraison as l";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON l.rowid = el.fk_target";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = l.rowid AND el.targettype = '".$this->element."'";
|
||||||
$sql.= " WHERE l.rowid = ".$id;
|
$sql.= " WHERE l.rowid = ".$id;
|
||||||
|
|
||||||
dol_syslog("Livraison::fetch sql=".$sql, LOG_DEBUG);
|
dol_syslog("Livraison::fetch sql=".$sql, LOG_DEBUG);
|
||||||
@ -265,15 +255,13 @@ class Livraison extends CommonObject
|
|||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->date_livraison = $this->db->jdate($obj->date_livraison);
|
$this->date_delivery = $this->db->jdate($obj->date_delivery);
|
||||||
$this->date_creation = $this->db->jdate($obj->date_creation);
|
$this->date_creation = $this->db->jdate($obj->date_creation);
|
||||||
$this->date_valid = $this->db->jdate($obj->date_valid);
|
$this->date_valid = $this->db->jdate($obj->date_valid);
|
||||||
$this->ref = $obj->ref;
|
$this->ref = $obj->ref;
|
||||||
$this->ref_client = $obj->ref_client;
|
$this->ref_customer = $obj->ref_customer;
|
||||||
$this->socid = $obj->fk_soc;
|
$this->socid = $obj->fk_soc;
|
||||||
$this->statut = $obj->fk_statut;
|
$this->statut = $obj->fk_statut;
|
||||||
$this->origin_id = $obj->origin_id;
|
|
||||||
$this->expedition_id = $obj->fk_expedition;
|
|
||||||
$this->user_author_id = $obj->fk_user_author;
|
$this->user_author_id = $obj->fk_user_author;
|
||||||
$this->user_valid_id = $obj->fk_user_valid;
|
$this->user_valid_id = $obj->fk_user_valid;
|
||||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison; // TODO obsolete
|
$this->adresse_livraison_id = $obj->fk_adresse_livraison; // TODO obsolete
|
||||||
@ -281,21 +269,11 @@ class Livraison extends CommonObject
|
|||||||
$this->note = $obj->note;
|
$this->note = $obj->note;
|
||||||
$this->note_public = $obj->note_public;
|
$this->note_public = $obj->note_public;
|
||||||
$this->modelpdf = $obj->model_pdf;
|
$this->modelpdf = $obj->model_pdf;
|
||||||
|
$this->origin = $obj->origin;
|
||||||
|
$this->origin_id = $obj->origin_id;
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
if ($this->origin_id)
|
|
||||||
{
|
|
||||||
if ($conf->commande->enabled)
|
|
||||||
{
|
|
||||||
$this->origin = "commande";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->origin = "propal";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->statut == 0) $this->brouillon = 1;
|
if ($this->statut == 0) $this->brouillon = 1;
|
||||||
|
|
||||||
$file = $conf->livraison->dir_output . "/" .get_exdir($livraison->id,2) . "/" . $this->id.".pdf";
|
$file = $conf->livraison->dir_output . "/" .get_exdir($livraison->id,2) . "/" . $this->id.".pdf";
|
||||||
@ -344,14 +322,14 @@ class Livraison extends CommonObject
|
|||||||
|
|
||||||
if ($user->rights->expedition->livraison->valider)
|
if ($user->rights->expedition->livraison->valider)
|
||||||
{
|
{
|
||||||
if (defined('LIVRAISON_ADDON'))
|
if ($conf->global->LIVRAISON_ADDON)
|
||||||
{
|
{
|
||||||
if (is_readable(DOL_DOCUMENT_ROOT .'/includes/modules/livraison/'.LIVRAISON_ADDON.'.php'))
|
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT .'/includes/modules/livraison/'.LIVRAISON_ADDON.'.php';
|
|
||||||
|
|
||||||
// Definition du nom de module de numerotation de commande
|
// Definition du nom de module de numerotation de commande
|
||||||
$modName=LIVRAISON_ADDON;
|
$modName = $conf->global->LIVRAISON_ADDON;
|
||||||
|
|
||||||
|
if (is_readable(DOL_DOCUMENT_ROOT .'/includes/modules/livraison/'.$modName.'.php'))
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT .'/includes/modules/livraison/'.$modName.'.php';
|
||||||
|
|
||||||
// Recuperation de la nouvelle reference
|
// Recuperation de la nouvelle reference
|
||||||
$objMod = new $modName($this->db);
|
$objMod = new $modName($this->db);
|
||||||
@ -367,7 +345,12 @@ class Livraison extends CommonObject
|
|||||||
|
|
||||||
// Tester si non deja au statut valide. Si oui, on arrete afin d'eviter
|
// Tester si non deja au statut valide. Si oui, on arrete afin d'eviter
|
||||||
// de decrementer 2 fois le stock.
|
// de decrementer 2 fois le stock.
|
||||||
$sql = "SELECT ref FROM ".MAIN_DB_PREFIX."livraison where ref='".$this->ref."' AND fk_statut <> 0";
|
$sql = "SELECT ref";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."livraison";
|
||||||
|
$sql.= " WHERE ref = '".$this->ref."'";
|
||||||
|
$sql.= " AND fk_statut <> 0";
|
||||||
|
$sql.= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -378,9 +361,14 @@ class Livraison extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."livraison ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."livraison SET";
|
||||||
$sql.= " SET ref='".addslashes($this->ref)."', fk_statut = 1, date_valid = ".$this->db->idate(mktime()).", fk_user_valid = ".$user->id;
|
$sql.= " ref='".addslashes($this->ref)."'";
|
||||||
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
$sql.= ", fk_statut = 1";
|
||||||
|
$sql.= ", date_valid = ".$this->db->idate(mktime());
|
||||||
|
$sql.= ", fk_user_valid = ".$user->id;
|
||||||
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
$sql.= " AND fk_statut = 0";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -390,7 +378,6 @@ class Livraison extends CommonObject
|
|||||||
|
|
||||||
//Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
//Enregistrement d'un mouvement de stock pour chaque produit de l'expedition
|
||||||
|
|
||||||
|
|
||||||
dol_syslog("livraison.class.php::valid enregistrement des mouvements");
|
dol_syslog("livraison.class.php::valid enregistrement des mouvements");
|
||||||
|
|
||||||
$sql = "SELECT cd.fk_product, cd.subprice, ld.qty ";
|
$sql = "SELECT cd.fk_product, cd.subprice, ld.qty ";
|
||||||
@ -491,8 +478,6 @@ class Livraison extends CommonObject
|
|||||||
$result=$expedition->fetch($sending_id);
|
$result=$expedition->fetch($sending_id);
|
||||||
|
|
||||||
$this->lignes = array();
|
$this->lignes = array();
|
||||||
$this->date_livraison = time();
|
|
||||||
$this->expedition_id = $sending_id;
|
|
||||||
|
|
||||||
for ($i = 0 ; $i < sizeof($expedition->lignes) ; $i++)
|
for ($i = 0 ; $i < sizeof($expedition->lignes) ; $i++)
|
||||||
{
|
{
|
||||||
@ -506,15 +491,15 @@ class Livraison extends CommonObject
|
|||||||
$this->lignes[$i] = $LivraisonLigne;
|
$this->lignes[$i] = $LivraisonLigne;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->origin = $expedition->origin;
|
$this->origin = $expedition->element;
|
||||||
$this->origin_id = $expedition->origin_id;
|
$this->origin_id = $expedition->id;
|
||||||
$this->note = $expedition->note;
|
$this->note = $expedition->note;
|
||||||
$this->fk_project = $expedition->fk_project;
|
$this->fk_project = $expedition->fk_project;
|
||||||
$this->date_livraison = $expedition->date_livraison;
|
$this->date_delivery = $expedition->date_delivery;
|
||||||
$this->adresse_livraison_id = $expedition->adresse_livraison_id; // TODO obsolete
|
$this->adresse_livraison_id = $expedition->adresse_livraison_id; // TODO obsolete
|
||||||
$this->fk_delivery_address = $expedition->adresse_livraison_id;
|
$this->fk_delivery_address = $expedition->adresse_livraison_id;
|
||||||
$this->socid = $expedition->socid;
|
$this->socid = $expedition->socid;
|
||||||
$this->ref_client = $expedition->ref_client;
|
$this->ref_customer = $expedition->ref_customer;
|
||||||
|
|
||||||
return $this->create($user);
|
return $this->create($user);
|
||||||
}
|
}
|
||||||
@ -570,6 +555,11 @@ class Livraison extends CommonObject
|
|||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraisondet";
|
||||||
$sql.= " WHERE fk_livraison = ".$this->id;
|
$sql.= " WHERE fk_livraison = ".$this->id;
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
|
{
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
||||||
|
$sql.= " WHERE fk_target = ".$this->id;
|
||||||
|
$sql.= " AND targettype = '".$this->element."'";
|
||||||
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison";
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
@ -605,12 +595,21 @@ class Livraison extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror()." - sql=$sql";
|
||||||
|
$this->db->rollback();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->lasterror()." - sql=$sql";
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->lasterror()." - sql=$sql";
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -765,7 +764,7 @@ class Livraison extends CommonObject
|
|||||||
$this->specimen=1;
|
$this->specimen=1;
|
||||||
$socid = rand(1, $num_socs);
|
$socid = rand(1, $num_socs);
|
||||||
$this->socid = $socids[$socid];
|
$this->socid = $socids[$socid];
|
||||||
$this->date_livraison = time();
|
$this->date_delivery = time();
|
||||||
$this->note_public='SPECIMEN';
|
$this->note_public='SPECIMEN';
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user