Show sending method in card
This commit is contained in:
parent
67a6083696
commit
cef4ed576f
@ -206,8 +206,9 @@ if ($_GET["action"] == 'setmod')
|
||||
|
||||
|
||||
/*
|
||||
* Affiche page
|
||||
* Viewe
|
||||
*/
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT."/includes/modules/expedition/";
|
||||
$html=new Form($db);
|
||||
|
||||
@ -242,107 +243,11 @@ if ($conf->global->MAIN_SUBMODULE_LIVRAISON)
|
||||
|
||||
dolibarr_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
|
||||
|
||||
// M<>thode de livraison
|
||||
$mods=array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."expedition_methode WHERE statut = 1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$mods[$i]=$obj->rowid;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="140">'.$langs->trans("Name").'</td><td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center" width="60">'.$langs->trans("Action").'</td>';
|
||||
print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
|
||||
print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if(is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
$var=true;
|
||||
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (substr($file, strlen($file) -12) == '.modules.php' && substr($file,0,19) == 'methode_expedition_')
|
||||
{
|
||||
$name = substr($file, 19, strlen($file) - 31);
|
||||
$classname = substr($file, 0, strlen($file) - 12);
|
||||
|
||||
require_once($dir.$file);
|
||||
|
||||
$module = new $classname();
|
||||
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]><td>";
|
||||
print $module->name;
|
||||
print "</td><td>\n";
|
||||
|
||||
print $module->description;
|
||||
|
||||
print '</td><td align="center">';
|
||||
|
||||
if (in_array($module->id, $mods))
|
||||
{
|
||||
if ($conf->global->EXPEDITION_ADDON != $name)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmethod&statut=0&module='.$name.'&moduleid='.$module->id.'">';
|
||||
print img_tick($langs->trans("Disable"));
|
||||
print '</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_tick($langs->trans("Activated"));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmethod&statut=1&module='.$name.'&moduleid='.$module->id.'">'.$langs->trans("Activate").'</a>';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
// Default
|
||||
print '<td align="center">';
|
||||
if ($conf->global->EXPEDITION_ADDON == $name)
|
||||
{
|
||||
print img_tick($langs->trans("Activate"));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&module='.$name.'&moduleid='.$module->id.'">'.$langs->trans("Default").'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
print '<td> </td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td><b>ERROR</b>: $dir is not a directory !</td></tr>\n";
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
||||
/*
|
||||
* Modeles de documents
|
||||
*/
|
||||
print '<br>';
|
||||
print_titre($langs->trans("SendingsReceiptModel"));
|
||||
|
||||
// Defini tableau def de modele invoice
|
||||
|
||||
@ -31,8 +31,8 @@ if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande
|
||||
|
||||
|
||||
/**
|
||||
\class Expedition
|
||||
\brief Classe de gestion des expeditions
|
||||
* \class Expedition
|
||||
* \brief Classe de gestion des expeditions
|
||||
*/
|
||||
class Expedition extends CommonObject
|
||||
{
|
||||
@ -80,21 +80,23 @@ class Expedition extends CommonObject
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php";
|
||||
$error = 0;
|
||||
/* On positionne en mode brouillon l'expedition */
|
||||
$this->brouillon = 1;
|
||||
|
||||
// Clean parameters
|
||||
$this->brouillon = 1;
|
||||
$this->tracking_number = sanitizeFileName($this->tracking_number);
|
||||
|
||||
$this->user = $user;
|
||||
|
||||
$this->expedition_method = sanitizeFileName($this->expedition_method);
|
||||
$this->tracking_number = sanitizeFileName($this->tracking_number);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (ref, date_creation, fk_user_author, date_expedition,";
|
||||
$sql.= " fk_soc, fk_expedition_methode, tracking_number, weight, size, width, height, weight_units, size_units";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES ('(PROV)', now(), $user->id, ".$this->db->idate($this->date_expedition);
|
||||
$sql.= ", ".$this->socid.",'". $this->expedition_method_id."','". $this->tracking_number."',".$this->weight.",".$this->sizeS.",".$this->sizeW.",".$this->sizeH.",".$this->weight_units.",".$this->size_units;
|
||||
$sql.= " VALUES ('(PROV)', ".$this->db->idate(gmmktime()).", ".$user->id.", ".$this->db->idate($this->date_expedition).",";
|
||||
$sql.= " ".$this->socid.",";
|
||||
$sql.= " ".($this->expedition_method_id>0?$this->expedition_method_id:"null").",";
|
||||
$sql.= " '". $this->tracking_number."',".$this->weight.",".$this->sizeS.",".$this->sizeW.",".$this->sizeH.",".$this->weight_units.",".$this->size_units;
|
||||
$sql.= ")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
@ -110,7 +112,7 @@ class Expedition extends CommonObject
|
||||
{
|
||||
if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty) > 0)
|
||||
{
|
||||
$error++;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,32 +120,32 @@ class Expedition extends CommonObject
|
||||
{
|
||||
if ($conf->commande->enabled)
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')';
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')';
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')';
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
//Todo: definir un statut
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')';
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
//Todo: definir un statut
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id;
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -777,29 +779,8 @@ class Expedition extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Get id of default expedition method
|
||||
*/
|
||||
function GetIdOfDefault()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT em.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition_methode as em";
|
||||
$sql.= " WHERE em.code = '".strtoupper($conf->global->EXPEDITION_ADDON)."'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
$this->default_method_id = $obj->rowid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Get tracking url status
|
||||
/**
|
||||
* Get tracking url status
|
||||
*/
|
||||
function GetUrlTrackingStatus()
|
||||
{
|
||||
|
||||
@ -316,8 +316,7 @@ if ($_GET["action"] == 'create')
|
||||
print "<tr><td>".$langs->trans("DeliveryMethod")."</td>";
|
||||
print '<td colspan="3">';
|
||||
$expe->fetch_delivery_methods();
|
||||
$expe->GetIdOfDefault();
|
||||
$html->select_array("expedition_method_id",$expe->meths,$expe->default_method_id,0,0,0,0,"",1);
|
||||
$html->select_array("expedition_method_id",$expe->meths,'',1,0,0,0,"",1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Tracking number
|
||||
@ -524,7 +523,8 @@ else
|
||||
$typeobject = $expedition->origin;
|
||||
$expedition->fetch_object();
|
||||
|
||||
if (strlen($expedition->tracking_number) && strlen($expedition->expedition_method_id)) {
|
||||
if (strlen($expedition->tracking_number))
|
||||
{
|
||||
$expedition->GetUrlTrackingStatus();
|
||||
}
|
||||
|
||||
@ -688,6 +688,15 @@ else
|
||||
print '<td colspan="3">'.$expedition->getLibStatut(4)."</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
// Sending method
|
||||
print '<tr><td>'.$langs->trans("SendingMethod").'</td>';
|
||||
print '<td colspan="3">';
|
||||
// Get code using getLabelFromKey
|
||||
$code=$langs->getLabelFromKey($db,$expedition->expedition_method_id,'expedition_methode','rowid','code');
|
||||
print $langs->trans("SendingMethod".strtoupper($code));
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Tracking Number
|
||||
print '<tr><td>'.$langs->trans("TrackingNumber").'</td>';
|
||||
print '<td>'.$expedition->tracking_number.'</td>';
|
||||
|
||||
@ -403,13 +403,14 @@ if ($_GET["action"] == 'create')
|
||||
* Mode creation
|
||||
* Creation d'une nouvelle fiche d'intervention
|
||||
*/
|
||||
|
||||
$societe=new Societe($db);
|
||||
if ($_GET["socid"] > 0)
|
||||
{
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch($_GET["socid"]);
|
||||
}
|
||||
|
||||
print_titre($langs->trans("AddIntervention"));
|
||||
print_fiche_titre($langs->trans("AddIntervention"));
|
||||
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
@ -429,7 +430,7 @@ if ($_GET["action"] == 'create')
|
||||
$modFicheinter = new $obj;
|
||||
$numpr = $modFicheinter->getNextValue($societe,$ficheinter);
|
||||
|
||||
if ($_GET["socid"])
|
||||
if ($_GET["socid"] > 0)
|
||||
{
|
||||
print "<form name='fichinter' action=\"fiche.php\" method=\"post\">";
|
||||
|
||||
|
||||
@ -371,18 +371,23 @@ class Translate {
|
||||
{
|
||||
// Translation is not available
|
||||
$newstr=$key;
|
||||
if (ereg('CurrencyShort([A-Z]+)$',$key,$reg))
|
||||
if (eregi('CurrencyShort([A-Z]+)$',$key,$reg))
|
||||
{
|
||||
global $db;
|
||||
//$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','labelshort');
|
||||
$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','code');
|
||||
}
|
||||
else if (ereg('Currency([A-Z]+)$',$key,$reg))
|
||||
else if (eregi('Currency([A-Z]+)$',$key,$reg))
|
||||
{
|
||||
global $db;
|
||||
$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','label');
|
||||
//print "xxx".$key."-".$value."\n";
|
||||
}
|
||||
else if (eregi('SendingMethod([0-9A-Z]+)$',$key,$reg))
|
||||
{
|
||||
global $db;
|
||||
$newstr=$this->getLabelFromKey($db,$reg[1],'expedition_methode','code','libelle');
|
||||
}
|
||||
return $this->convToOutputCharset($newstr);
|
||||
}
|
||||
}
|
||||
@ -533,7 +538,6 @@ class Translate {
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
// Test if file is in lang directory
|
||||
foreach($this->dir as $searchdir)
|
||||
{
|
||||
@ -575,11 +579,13 @@ class Translate {
|
||||
/**
|
||||
* \brief Return a label for a key. Store key-label in a cache.
|
||||
* \param db Database handler
|
||||
* \param key Key to get label
|
||||
* \param key Key to get label (key in language file)
|
||||
* \param tablename Table name without prefix
|
||||
* \param fieldkey Field for key
|
||||
* \param fieldlabel Field for label
|
||||
* \param fieldval Value to find record
|
||||
* \return string Label
|
||||
* \remarks This function can be used to get label in database but more often to get code from key id.
|
||||
*/
|
||||
function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user