Add tracking url
This commit is contained in:
parent
3bae66626b
commit
55552d87d7
@ -15,8 +15,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,13 +84,16 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
|
||||||
|
$this->expedition_method = sanitize_string($this->expedition_method);
|
||||||
|
$this->tracking_number = sanitize_string($this->tracking_number);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition";
|
||||||
$sql.= ", fk_soc";
|
$sql.= ", fk_soc, fk_expedition_methode, tracking_number";
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
$sql.= " VALUES ('(PROV)', ".$this->db->idate(mktime()).", $user->id, ".$this->db->idate($this->date_expedition);
|
$sql.= " VALUES ('(PROV)', ".$this->db->idate(mktime()).", $user->id, ".$this->db->idate($this->date_expedition);
|
||||||
$sql.= ", ".$this->socid;
|
$sql.= ", ".$this->socid.",'". $this->expedition_method_id."','". $this->tracking_number."'";
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
@ -204,6 +206,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
$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.fk_user_author, e.fk_statut";
|
||||||
$sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison";
|
$sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison";
|
||||||
|
$sql.= ", e.fk_expedition_methode, e.tracking_number";
|
||||||
if ($conf->commande->enabled)
|
if ($conf->commande->enabled)
|
||||||
{
|
{
|
||||||
$sql.=", ce.fk_commande as origin_id";
|
$sql.=", ce.fk_commande as origin_id";
|
||||||
@ -245,6 +248,12 @@ class Expedition extends CommonObject
|
|||||||
$this->date = $obj->date_expedition;
|
$this->date = $obj->date_expedition;
|
||||||
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
|
$this->adresse_livraison_id = $obj->fk_adresse_livraison;
|
||||||
$this->modelpdf = $obj->model_pdf;
|
$this->modelpdf = $obj->model_pdf;
|
||||||
|
$this->expedition_method_id = $obj->fk_expedition_methode;
|
||||||
|
$this->tracking_number = $obj->tracking_number;
|
||||||
|
|
||||||
|
if (strlen($this->tracking_number) && strlen($this->expedition_method_id)) {
|
||||||
|
$this->GetUrlTrackingStatus();
|
||||||
|
}
|
||||||
|
|
||||||
if ($conf->commande->enabled)
|
if ($conf->commande->enabled)
|
||||||
{
|
{
|
||||||
@ -734,7 +743,7 @@ class Expedition extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Fecth deliveries method and return an array
|
Fetch deliveries method and return an array
|
||||||
*/
|
*/
|
||||||
function fetch_delivery_methods()
|
function fetch_delivery_methods()
|
||||||
{
|
{
|
||||||
@ -742,7 +751,7 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
$sql = "SELECT em.rowid, em.libelle";
|
$sql = "SELECT em.rowid, em.libelle";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em";
|
||||||
$sql.= " WHERE em.statut = 1";
|
$sql.= " WHERE em.statut = 1 ORDER BY em.libelle ASC";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -753,6 +762,34 @@ class Expedition extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
Get tracking url status
|
||||||
|
*/
|
||||||
|
function GetUrlTrackingStatus()
|
||||||
|
{
|
||||||
|
$sql = "SELECT em.code";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em";
|
||||||
|
$sql.= " WHERE em.rowid = ".$this->expedition_method_id;
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
if ($obj = $this->db->fetch_object($resql))
|
||||||
|
{
|
||||||
|
$code = $obj->code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($code) {
|
||||||
|
$classe = "methode_expedition_".strtolower($code);
|
||||||
|
include "./mods/methode_expedition_".strtolower($code).".modules.php";
|
||||||
|
$obj = new $classe;
|
||||||
|
$url = $obj->provider_url_status($this->tracking_number);
|
||||||
|
$this->tracking_url = sprintf('<a target="_blank" href="%s">url</a>',$url,$url);
|
||||||
|
} else {
|
||||||
|
$this->tracking_url = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
||||||
* Copyright (C) 2005-2008 Régis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2008 Régis Houssin <regis@dolibarr.fr>
|
||||||
@ -15,8 +15,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Code identique a /expedition/commande.php
|
// Code identique a /expedition/commande.php
|
||||||
@ -48,7 +47,7 @@ if (! $user->rights->expedition->lire)
|
|||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
// Sécurité accés client
|
// Security customer access
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
$action = '';
|
$action = '';
|
||||||
@ -81,8 +80,9 @@ if ($_POST["action"] == 'add')
|
|||||||
$object->fetch($expedition->origin_id);
|
$object->fetch($expedition->origin_id);
|
||||||
//$object->fetch_lines();
|
//$object->fetch_lines();
|
||||||
|
|
||||||
|
|
||||||
$expedition->socid = $object->socid;
|
$expedition->socid = $object->socid;
|
||||||
|
$expedition->expedition_method_id = $_POST["expedition_method_id"];
|
||||||
|
$expedition->tracking_number = $_POST["tracking_number"];
|
||||||
|
|
||||||
for ($i = 0 ; $i < sizeof($object->lignes) ; $i++)
|
for ($i = 0 ; $i < sizeof($object->lignes) ; $i++)
|
||||||
{
|
{
|
||||||
@ -196,6 +196,8 @@ $formfile = new FormFile($db);
|
|||||||
if ($_GET["action"] == 'create')
|
if ($_GET["action"] == 'create')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$expe = new Expedition($db);
|
||||||
|
|
||||||
print_titre($langs->trans("CreateASending"));
|
print_titre($langs->trans("CreateASending"));
|
||||||
if (! $origin)
|
if (! $origin)
|
||||||
{
|
{
|
||||||
@ -240,7 +242,7 @@ if ($_GET["action"] == 'create')
|
|||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td>';
|
print '<tr><td width="30%">';
|
||||||
if ($conf->commande->enabled)
|
if ($conf->commande->enabled)
|
||||||
{
|
{
|
||||||
print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref;
|
print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id.'">'.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref;
|
||||||
@ -283,6 +285,18 @@ if ($_GET["action"] == 'create')
|
|||||||
print '<tr><td colspan="3">'.$langs->trans("NotePrivate").': '.nl2br($object->note)."</td></tr>";
|
print '<tr><td colspan="3">'.$langs->trans("NotePrivate").': '.nl2br($object->note)."</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delivery method
|
||||||
|
print "<tr><td>".$langs->trans("DeliveryMethod")."</td>";
|
||||||
|
print '<td colspan="3">';
|
||||||
|
|
||||||
|
$expe->fetch_delivery_methods();
|
||||||
|
$html->select_array("expedition_method_id",$expe->meths);
|
||||||
|
print "</td></tr>\n";
|
||||||
|
// Tracking number
|
||||||
|
print "<tr><td>".$langs->trans("TrackingNumber")."</td>";
|
||||||
|
print '<td colspan="3">';
|
||||||
|
print '<input name="tracking_number" size="20">';
|
||||||
|
print "</td></tr>\n";
|
||||||
print "</table>";
|
print "</table>";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -442,7 +456,7 @@ if ($_GET["action"] == 'create')
|
|||||||
else
|
else
|
||||||
/* *************************************************************************** */
|
/* *************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* Mode vue et edition */
|
/* Edit and view mode */
|
||||||
/* */
|
/* */
|
||||||
/* *************************************************************************** */
|
/* *************************************************************************** */
|
||||||
{
|
{
|
||||||
@ -525,7 +539,7 @@ else
|
|||||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||||
print '<td colspan="3">'.$expedition->ref.'</td></tr>';
|
print '<td colspan="3">'.$expedition->ref.'</td></tr>';
|
||||||
|
|
||||||
// Client
|
// Customer
|
||||||
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
|
print '<tr><td width="20%">'.$langs->trans("Customer").'</td>';
|
||||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||||
print "</tr>";
|
print "</tr>";
|
||||||
@ -572,11 +586,16 @@ else
|
|||||||
print '<td colspan="3">'.$totalVolume.' '.measuring_units_string($volumeUnit,"volume")."</td>\n";
|
print '<td colspan="3">'.$totalVolume.' '.measuring_units_string($volumeUnit,"volume")."</td>\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Statut
|
// Status
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td>';
|
print '<tr><td>'.$langs->trans("Status").'</td>';
|
||||||
print '<td colspan="3">'.$expedition->getLibStatut(4)."</td>\n";
|
print '<td colspan="3">'.$expedition->getLibStatut(4)."</td>\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Tracking Number
|
||||||
|
print '<tr><td>'.$langs->trans("TrackingNumber").'</td>';
|
||||||
|
print '<td>'.$expedition->tracking_number.'</td><td colspan="2">'.$expedition->tracking_url."</td>\n";
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user