*
* 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
@@ -50,13 +50,13 @@ $type='delivery';
if ($action == 'updateMask')
{
- $maskconstdelivery=GETPOST('maskconstdelivery','alpha');
- $maskdelivery=GETPOST('maskdelivery','alpha');
- if ($maskconstdelivery) $res = dolibarr_set_const($db,$maskconstdelivery,$maskdelivery,'chaine',0,'',$conf->entity);
+ $maskconstdelivery=GETPOST('maskconstdelivery','alpha');
+ $maskdelivery=GETPOST('maskdelivery','alpha');
+ if ($maskconstdelivery) $res = dolibarr_set_const($db,$maskconstdelivery,$maskdelivery,'chaine',0,'',$conf->entity);
- if (! $res > 0) $error++;
+ if (! $res > 0) $error++;
- if (! $error)
+ if (! $error)
{
$mesg = "".$langs->trans("SetupSaved")."";
}
@@ -68,12 +68,12 @@ if ($action == 'updateMask')
if ($action == 'set_DELIVERY_FREE_TEXT')
{
- $free=GETPOST('DELIVERY_FREE_TEXT','alpha');
+ $free=GETPOST('DELIVERY_FREE_TEXT','alpha');
$res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
- if (! $error)
+ if (! $error)
{
$mesg = "".$langs->trans("SetupSaved")."";
}
@@ -85,58 +85,58 @@ if ($action == 'set_DELIVERY_FREE_TEXT')
if ($action == 'specimen')
{
- $modele=GETPOST('module','alpha');
+ $modele=GETPOST('module','alpha');
- $sending = new Livraison($db);
- $sending->initAsSpecimen();
+ $sending = new Livraison($db);
+ $sending->initAsSpecimen();
- // Search template files
- $file=''; $classname=''; $filefound=0;
- $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
- foreach($dirmodels as $reldir)
- {
- $file=dol_buildpath($reldir."core/modules/livraison/pdf/pdf_".$modele.".modules.php",0);
- if (file_exists($file))
- {
- $filefound=1;
- $classname = "pdf_".$modele;
- break;
- }
- }
+ // Search template files
+ $file=''; $classname=''; $filefound=0;
+ $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+ foreach($dirmodels as $reldir)
+ {
+ $file=dol_buildpath($reldir."core/modules/livraison/pdf/pdf_".$modele.".modules.php",0);
+ if (file_exists($file))
+ {
+ $filefound=1;
+ $classname = "pdf_".$modele;
+ break;
+ }
+ }
- if ($filefound)
- {
- require_once $file;
+ if ($filefound)
+ {
+ require_once $file;
- $module = new $classname($db);
+ $module = new $classname($db);
- if ($module->write_file($sending,$langs) > 0)
- {
- header("Location: ".DOL_URL_ROOT."/document.php?modulepart=livraison&file=SPECIMEN.pdf");
- return;
- }
- else
- {
- $mesg=''.$module->error.'';
- dol_syslog($module->error, LOG_ERR);
- }
- }
- else
- {
- $mesg=''.$langs->trans("ErrorModuleNotFound").'';
- dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
- }
+ if ($module->write_file($sending,$langs) > 0)
+ {
+ header("Location: ".DOL_URL_ROOT."/document.php?modulepart=livraison&file=SPECIMEN.pdf");
+ return;
+ }
+ else
+ {
+ $mesg=''.$module->error.'';
+ dol_syslog($module->error, LOG_ERR);
+ }
+ }
+ else
+ {
+ $mesg=''.$langs->trans("ErrorModuleNotFound").'';
+ dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+ }
}
if ($action == 'set')
-{
- $ret = addDocumentModel($value, $type, $label, $scandir);
+{
+ $ret = addDocumentModel($value, $type, $label, $scandir);
}
if ($action == 'del')
{
$ret = delDocumentModel($value, $type);
- if ($ret > 0)
+ if ($ret > 0)
{
if ($conf->global->LIVRAISON_ADDON_PDF == "$value") dolibarr_del_const($db, 'LIVRAISON_ADDON_PDF',$conf->entity);
}
@@ -146,17 +146,17 @@ if ($action == 'setdoc')
{
if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
{
- // La constante qui a ete lue en avant du nouveau set
- // on passe donc par une variable pour avoir un affichage coherent
+ // La constante qui a ete lue en avant du nouveau set
+ // on passe donc par une variable pour avoir un affichage coherent
$conf->global->LIVRAISON_ADDON_PDF = $value;
}
// On active le modele
- $ret = delDocumentModel($value, $type);
- if ($ret > 0)
- {
- $ret = addDocumentModel($value, $type, $label, $scandir);
- }
+ $ret = delDocumentModel($value, $type);
+ if ($ret > 0)
+ {
+ $ret = addDocumentModel($value, $type, $label, $scandir);
+ }
}
if ($action == 'setmod')
@@ -164,7 +164,7 @@ if ($action == 'setmod')
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
- dolibarr_set_const($db, "LIVRAISON_ADDON",$value,'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "LIVRAISON_ADDON",$value,'chaine',0,'',$conf->entity);
}
@@ -189,11 +189,15 @@ $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
$head[$h][1] = $langs->trans("Setup");
$h++;
+$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php";
+$head[$h][1] = $langs->trans("Carriers");
+$h++;
+
if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{
- $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
- $head[$h][1] = $langs->trans("Sending");
- $h++;
+ $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
+ $head[$h][1] = $langs->trans("Sending");
+ $h++;
}
$head[$h][0] = DOL_URL_ROOT."/admin/livraison.php";
@@ -222,34 +226,34 @@ clearstatcache();
foreach ($dirmodels as $reldir)
{
- $dir = dol_buildpath($reldir."core/modules/livraison/");
+ $dir = dol_buildpath($reldir."core/modules/livraison/");
- if (is_dir($dir))
- {
- $handle = opendir($dir);
- if (is_resource($handle))
- {
- $var=true;
- while (($file = readdir($handle))!==false)
- {
- if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php')
- {
- $file = substr($file, 0, dol_strlen($file)-4);
+ if (is_dir($dir))
+ {
+ $handle = opendir($dir);
+ if (is_resource($handle))
+ {
+ $var=true;
+ while (($file = readdir($handle))!==false)
+ {
+ if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+ {
+ $file = substr($file, 0, dol_strlen($file)-4);
- require_once DOL_DOCUMENT_ROOT ."/core/modules/livraison/".$file.'.php';
+ require_once DOL_DOCUMENT_ROOT ."/core/modules/livraison/".$file.'.php';
- $module = new $file;
+ $module = new $file;
- // Show modules according to features level
- if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
- if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+ // Show modules according to features level
+ if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+ if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
- if ($module->isEnabled())
- {
- $var=!$var;
- print '| '.$module->nom." | \n";
- print $module->info();
- print ' | ';
+ if ($module->isEnabled())
+ {
+ $var=!$var;
+ print '
| '.$module->nom." | \n";
+ print $module->info();
+ print ' | ';
// Show example of numbering module
print '';
@@ -259,48 +263,48 @@ foreach ($dirmodels as $reldir)
else print $tmp;
print ' | '."\n";
- print '';
- if ($conf->global->LIVRAISON_ADDON == "$file")
- {
- print img_picto($langs->trans("Activated"),'switch_on');
- }
- else
- {
- print ''.img_picto($langs->trans("Disabled"),'switch_off').'';
- }
- print ' | ';
+ print '';
+ if ($conf->global->LIVRAISON_ADDON == "$file")
+ {
+ print img_picto($langs->trans("Activated"),'switch_on');
+ }
+ else
+ {
+ print ''.img_picto($langs->trans("Disabled"),'switch_off').'';
+ }
+ print ' | ';
- $livraison=new Livraison($db);
- $livraison->initAsSpecimen();
+ $livraison=new Livraison($db);
+ $livraison->initAsSpecimen();
- // Info
- $htmltooltip='';
- $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
';
- $nextval=$module->getNextValue($mysoc,$livraison);
- if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
- {
- $htmltooltip.=''.$langs->trans("NextValue").': ';
- if ($nextval)
- {
- $htmltooltip.=$nextval.'
';
- }
- else
- {
- $htmltooltip.=$langs->trans($module->error).'
';
- }
- }
+ // Info
+ $htmltooltip='';
+ $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
';
+ $nextval=$module->getNextValue($mysoc,$livraison);
+ if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
+ {
+ $htmltooltip.=''.$langs->trans("NextValue").': ';
+ if ($nextval)
+ {
+ $htmltooltip.=$nextval.'
';
+ }
+ else
+ {
+ $htmltooltip.=$langs->trans($module->error).'
';
+ }
+ }
- print '';
- print $form->textwithpicto('',$htmltooltip,1,0);
- print ' | ';
+ print '';
+ print $form->textwithpicto('',$htmltooltip,1,0);
+ print ' | ';
- print '
';
- }
- }
- }
- closedir($handle);
- }
- }
+ print '';
+ }
+ }
+ }
+ closedir($handle);
+ }
+ }
}
print '';
@@ -352,77 +356,77 @@ clearstatcache();
$var=true;
foreach ($dirmodels as $reldir)
{
- $dir = dol_buildpath($reldir."core/modules/livraison/pdf/");
+ $dir = dol_buildpath($reldir."core/modules/livraison/pdf/");
- if (is_dir($dir))
- {
- $handle = opendir($dir);
- if (is_resource($handle))
- {
- while (($file = readdir($handle))!==false)
- {
- if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
- {
- $name = substr($file, 4, dol_strlen($file) - 16);
- $classname = substr($file, 0, dol_strlen($file) - 12);
+ if (is_dir($dir))
+ {
+ $handle = opendir($dir);
+ if (is_resource($handle))
+ {
+ while (($file = readdir($handle))!==false)
+ {
+ if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
+ {
+ $name = substr($file, 4, dol_strlen($file) - 16);
+ $classname = substr($file, 0, dol_strlen($file) - 12);
- $var=!$var;
+ $var=!$var;
- print '| ';
- print $name;
- print " | \n";
- require_once $dir.$file;
- $module = new $classname($db);
+ print ' |
| ';
+ print $name;
+ print " | \n";
+ require_once $dir.$file;
+ $module = new $classname($db);
- print $module->description;
- print ' | ';
+ print $module->description;
+ print '';
- // Activ
- if (in_array($name, $def))
- {
- print "\n";
- print 'scandir.'&label='.urlencode($module->name).'">';
- print img_picto($langs->trans("Enabled"),'switch_on');
- print '';
- print " | ";
- }
- else
- {
- print "\n";
- print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'';
- print " | ";
- }
+ // Activ
+ if (in_array($name, $def))
+ {
+ print "\n";
+ print 'scandir.'&label='.urlencode($module->name).'">';
+ print img_picto($langs->trans("Enabled"),'switch_on');
+ print '';
+ print " | ";
+ }
+ else
+ {
+ print "\n";
+ print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'';
+ print " | ";
+ }
- // Defaut
- print "";
- if ($conf->global->LIVRAISON_ADDON_PDF == "$name")
- {
- print img_picto($langs->trans("Default"),'on');
- }
- else
- {
- print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'';
- }
- print ' | ';
+ // Defaut
+ print "";
+ if ($conf->global->LIVRAISON_ADDON_PDF == "$name")
+ {
+ print img_picto($langs->trans("Default"),'on');
+ }
+ else
+ {
+ print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'';
+ }
+ print ' | ';
- // Info
- $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
- $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
- $htmltooltip.='
'.$langs->trans("FeaturesSupported").':';
- $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
- print '';
- print $form->textwithpicto('',$htmltooltip,1,0);
- print ' | ';
- print '';
- print ''.img_object($langs->trans("Preview"),'sending').'';
- print ' | ';
+ // Info
+ $htmltooltip = ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+ $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+ $htmltooltip.='
'.$langs->trans("FeaturesSupported").':';
+ $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+ print '';
+ print $form->textwithpicto('',$htmltooltip,1,0);
+ print ' | ';
+ print '';
+ print ''.img_object($langs->trans("Preview"),'sending').'';
+ print ' | ';
- print '
';
- }
- }
- closedir($handle);
- }
- }
+ print '';
+ }
+ }
+ closedir($handle);
+ }
+ }
}
print '';
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 1840713b0e6..ca8c5ea2dfe 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -1168,6 +1168,65 @@ class Expedition extends CommonObject
}
}
+ /**
+ * Fetch all deliveries method and return an array. Load array this->listmeths.
+ *
+ * @return void
+ */
+ function all_delivery_methods()
+ {
+ global $langs;
+ $meths = array();
+ $i=0;
+
+ $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.active";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em";
+ //$sql.= " ORDER BY em.libelle ASC";
+
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ while ($obj = $this->db->fetch_object($resql))
+ {
+ $this->listmeths[$i][rowid] = $obj->rowid;
+ $this->listmeths[$i][code] = $obj->code;
+ $label=$langs->trans('SendingMethod'.$obj->code);
+ $this->listmeths[$i][libelle] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle);
+ $this->listmeths[$i][description] = $obj->description;
+ $this->listmeths[$i][active] = $obj->active;
+ $i++;
+ }
+ }
+ }
+
+ /**
+ * Activate delivery method.
+ * @param id $id id method to activate
+ * @return void
+ */
+ function activ_delivery_method($id)
+ {
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1';
+ $sql.= ' WHERE rowid='.$id;
+
+ $resql = $this->db->query($sql);
+
+ }
+
+ /**
+ * DesActivate delivery method.
+ * @param id $id id method to desactivate
+ * @return void
+ */
+ function disable_delivery_method($id)
+ {
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0';
+ $sql.= ' WHERE rowid='.$id;
+
+ $resql = $this->db->query($sql);
+
+ }
+
/**
* Get tracking url status
*