WIP : Admin for Carriers

This commit is contained in:
frederic34 2013-02-23 15:23:33 +01:00
parent c8872d7e98
commit 9333fdb97f
9 changed files with 54 additions and 244 deletions

View File

@ -41,17 +41,25 @@ $object = new Expedition($db);
/*
* Actions
*/
if ($action==setvalue AND $carrier)
//if ($action==setvalue AND $carrier)
if ($action==setvalue)
{
//$object->update_delivery_method($carrier);
// need to add check on values
$object->update[code]=GETPOST('code','alpha');
$object->update[libelle]=GETPOST('libelle','alpha');
$object->update[description]=GETPOST('description','alpha');
$object->update[tracking]=GETPOST('tracking','alpha');
$object->update_delivery_method($carrier);
header("Location: carrier.php");
exit;
}
if ($action==activate_carrier AND $carrier)
if ($action==activate_carrier AND $carrier!='')
{
$object->activ_delivery_method($carrier);
}
if ($action==disable_carrier AND $carrier)
if ($action==disable_carrier AND $carrier!='')
{
$object->disable_delivery_method($carrier);
}
@ -105,7 +113,7 @@ dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
if ($action=='edit_carrier' || $action=='setvalue')
{
// Carrier Edit
if ($carrier) $object->list_delivery_methods($carrier);
if ($carrier!='') $object->list_delivery_methods($carrier);
print_titre($langs->trans("CarrierEdit"));
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?carrier='.$carrier.'">';
@ -131,7 +139,7 @@ if ($action=='edit_carrier' || $action=='setvalue')
$var=!$var;
print '<tr '.$bc[$var].'><td class="fieldrequired">';
print $langs->trans("Name").'</td><td>';
print '<input size="32" type="text" name="name" value="'.$object->listmeths[0][libelle].'">';
print '<input size="32" type="text" name="libelle" value="'.$object->listmeths[0][libelle].'">';
print '</td></tr>';
$var=!$var;
@ -194,14 +202,7 @@ else
print '<a href="carrier.php?action=disable_carrier&amp;carrier='.$object->listmeths[$i][rowid].'">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
}
print '</td><td align="center">';
if($object->listmeths[$i][editable] == 1)
{
print '<a href="carrier.php?action=edit_carrier&amp;carrier='.$object->listmeths[$i][rowid].'">'.img_picto($langs->trans("Edit"),'edit').'</a>';
}
else
{
print '&nbsp;';
}
print '<a href="carrier.php?action=edit_carrier&amp;carrier='.$object->listmeths[$i][rowid].'">'.img_picto($langs->trans("Edit"),'edit').'</a>';
print '</td>';
print "</tr>\n";
}
@ -215,4 +216,4 @@ else
llxFooter();
$db->close();
?>
?>

View File

@ -1,55 +0,0 @@
<?PHP
/*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/modules/expedition/methode_expedition_chrono.modules.php
* \ingroup expedition
*/
include_once "methode_expedition.modules.php";
/**
* Class to manage shipment Chronopost
*/
class methode_expedition_chrono extends ModeleShippingMethod
{
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db=0)
{
$this->db = $db;
$this->id = 8; // Do not change this value
$this->code = "CHRONO"; // Do not change this value
$this->name = "Chronopost";
$this->description = "Chronopost";
}
/**
* Return URL of provider
*
* @param string $tracking_number Tracking number
* @return string URL for tracking
*/
function provider_url_status($tracking_number)
{
return sprintf("http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?listeNumeros=%s",$tracking_number);
}
}
?>

View File

@ -1,55 +0,0 @@
<?PHP
/*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* \file htdocs/core/modules/expedition/methode_expedition_gls.modules.php
* \ingroup expedition
*/
include_once "methode_expedition.modules.php";
/**
* Class to manage shipment GLS
*/
class methode_expedition_gls extends ModeleShippingMethod
{
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db=0)
{
$this->db = $db;
$this->id = 7; // Do not change this value
$this->code = "GLS"; // Do not change this value
$this->name = "GLS";
$this->description = "General Logistics Systems";
}
/**
* Return URL of provider
*
* @param string $tracking_number Tracking number
* @return string URL for tracking
*/
function provider_url_status($tracking_number)
{
return sprintf("http://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/FR01/FR/5004.htm?txtAction=71000&txtRefNo=%s",$tracking_number);
}
}
?>

View File

@ -1,55 +0,0 @@
<?PHP
/*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/*
* \file htdocs/core/modules/expedition/methode_expedition_kiala.modules.php
* \ingroup expedition
*/
include_once "methode_expedition.modules.php";
Class methode_expedition_kiala extends ModeleShippingMethod
{
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function methode_expedition_kiala($db=0)
{
$this->db = $db;
$this->id = 6; // Do not change this value
$this->code = "KIALA"; // Do not change this value
$this->name = "KIALA";
$this->description = "KIALA";
}
/**
* Return URL of provider
*
* @param string $tracking_number Tracking number
* @return string URL for tracking
*/
function provider_url_status($tracking_number)
{
return sprintf("http://www.kiala.fr/tnt/delivery/%s",$tracking_number);
}
}
?>

View File

@ -1,54 +0,0 @@
<?PHP
/*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/*
* \file htdocs/core/modules/expedition/methode_expedition_ups.modules.php
* \ingroup expedition
*/
include_once "methode_expedition.modules.php";
class methode_expedition_ups extends ModeleShippingMethod
{
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function methode_expedition_ups($db=0)
{
$this->db = $db;
$this->id = 5; // Do not change this value
$this->code = "UPS"; // Do not change this value
$this->name = "UPS";
$this->description = "United Parcel Service";
}
/**
* Return URL of provider
*
* @param string $tracking_number Tracking number
* @return string URL for tracking
*/
function provider_url_status($tracking_number)
{
return sprintf("http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber2=&InquiryNumber3=&tracknums_displayed=3&loc=fr_FR&TypeOfInquiryNumber=T&HTMLVersion=4.0&InquiryNumber22=&InquiryNumber32=&track=Track&Suivi.x=64&Suivi.y=7&Suivi=Valider&InquiryNumber1=%s",$tracking_number);
}
}
?>

View File

@ -1181,7 +1181,7 @@ class Expedition extends CommonObject
$sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em";
if ($id) $sql.= " WHERE em.rowid=".$id;
if ($id!='') $sql.= " WHERE em.rowid=".$id;
$resql = $this->db->query($sql);
if ($resql)
@ -1196,8 +1196,6 @@ class Expedition extends CommonObject
if ($obj->tracking)
{
$this->listmeths[$i][tracking] = $obj->tracking;
// editable or hardcoded
$this->listmeths[$i][editable] = 1;
}
else
{
@ -1219,6 +1217,32 @@ class Expedition extends CommonObject
}
}
/**
* Update/create delivery method.
* @param id $id id method to activate
* @return void
*/
function update_delivery_method($id='')
{
if ($id=='')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (rowid, code, libelle, description, tracking)";
$sql.=" VALUES ('','".$this->update[code]."','".$this->update[libelle]."','".$this->update[description]."','".$this->update[tracking]."')";
$resql = $this->db->query($sql);
}
else
{
$sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET";
$sql.= " code='".$this->update[code]."'";
$sql.= ",libelle='".$this->update[libelle]."'";
$sql.= ",description='".$this->update[description]."'";
$sql.= ",tracking='".$this->update[tracking]."'";
$sql.= " WHERE rowid=".$id;
$resql = $this->db->query($sql);
}
}
/**
* Activate delivery method.
* @param id $id id method to activate

View File

@ -33,8 +33,7 @@ INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active)
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (2,'TRANS','Transporter','Generic transporter','',1);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (3,'COLSUI','Colissimo Suivi','Colissimo Suivi','',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max','',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (5,'UPS','UPS','United Parcel Service','',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (6,'KIALA','KIALA','Relais Kiala','',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (7,'GLS','GLS','General Logistics Systems','',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (8,'CHRONO','Chronopost','Chronopost','',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'EDIT','EDITABLE','Transporteur Modifiable','http://www.website.com/dir/{TRACKID}',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (5,'UPS','UPS','United Parcel Service','http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber2=&InquiryNumber3=&tracknums_displayed=3&loc=fr_FR&TypeOfInquiryNumber=T&HTMLVersion=4.0&InquiryNumber22=&InquiryNumber32=&track=Track&Suivi.x=64&Suivi.y=7&Suivi=Valider&InquiryNumber1={TRACKID}',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (6,'KIALA','KIALA','Relais Kiala','http://www.kiala.fr/tnt/delivery/{TRACKID}',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (7,'GLS','GLS','General Logistics Systems','http://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/FR01/FR/5004.htm?txtAction=71000&txtRefNo={TRACKID}',0);
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (8,'CHRONO','Chronopost','Chronopost','http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?listeNumeros={TRACKID}',0);

View File

@ -52,4 +52,9 @@ INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (8,'CHRONO','Chronopost','Chronopost',0);
ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(256) NOT NULL AFTER description;
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'EDIT','EDITABLE','Transporteur Modifiable','http://www.website.com/dir/{TRACKID}',0);
ALTER TABLE llx_c_shipment_mode MODIFY COLUMN rowid INT(11) NOT NULL AUTO_INCREMENT;
INSERT INTO llx_c_shipment_mode (code,libelle,description,tracking,active) VALUES ('UPS','UPS','United Parcel Service','http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber2=&InquiryNumber3=&tracknums_displayed=3&loc=fr_FR&TypeOfInquiryNumber=T&HTMLVersion=4.0&InquiryNumber22=&InquiryNumber32=&track=Track&Suivi.x=64&Suivi.y=7&Suivi=Valider&InquiryNumber1={TRACKID}',0);
INSERT INTO llx_c_shipment_mode (code,libelle,description,tracking,active) VALUES ('KIALA','KIALA','Relais Kiala','http://www.kiala.fr/tnt/delivery/{TRACKID}',0);
INSERT INTO llx_c_shipment_mode (code,libelle,description,tracking,active) VALUES ('GLS','GLS','General Logistics Systems','http://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/FR01/FR/5004.htm?txtAction=71000&txtRefNo={TRACKID}',0);
INSERT INTO llx_c_shipment_mode (code,libelle,description,tracking,active) VALUES ('CHRONO','Chronopost','Chronopost','http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?listeNumeros={TRACKID}',0);

View File

@ -18,7 +18,7 @@
create table llx_c_shipment_mode
(
rowid integer PRIMARY KEY,
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
code varchar(30) NOT NULL,
libelle varchar(50) NOT NULL,