normalize and simplify code
This commit is contained in:
parent
88256b7531
commit
c44e9d6044
@ -65,9 +65,9 @@ if ($action == 'updateMask')
|
|||||||
if (isset($res))
|
if (isset($res))
|
||||||
{
|
{
|
||||||
if ($res < 0)
|
if ($res < 0)
|
||||||
setEventMessage($langs->trans("Error"), 'errors');
|
|
||||||
else
|
|
||||||
setEventMessage($langs->trans("SetupSaved"));
|
setEventMessage($langs->trans("SetupSaved"));
|
||||||
|
else
|
||||||
|
setEventMessage($langs->trans("Error"), 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +77,9 @@ else if ($action == 'set_SHIPPING_FREE_TEXT')
|
|||||||
$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
|
$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
if ($res < 0)
|
if ($res < 0)
|
||||||
setEventMessage($langs->trans("Error"), 'errors');
|
|
||||||
else
|
|
||||||
setEventMessage($langs->trans("SetupSaved"));
|
setEventMessage($langs->trans("SetupSaved"));
|
||||||
|
else
|
||||||
|
setEventMessage($langs->trans("Error"), 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
|
else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
|
||||||
@ -88,9 +88,9 @@ else if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
|
|||||||
$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
|
$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
if ($res < 0)
|
if ($res < 0)
|
||||||
setEventMessage($langs->trans("Error"), 'errors');
|
|
||||||
else
|
|
||||||
setEventMessage($langs->trans("SetupSaved"));
|
setEventMessage($langs->trans("SetupSaved"));
|
||||||
|
else
|
||||||
|
setEventMessage($langs->trans("Error"), 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($action == 'specimen')
|
else if ($action == 'specimen')
|
||||||
@ -173,12 +173,7 @@ else if ($action == 'setdoc')
|
|||||||
|
|
||||||
else if ($action == 'setmodel')
|
else if ($action == 'setmodel')
|
||||||
{
|
{
|
||||||
$res = dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
if ($res < 0)
|
|
||||||
setEventMessage($langs->trans("Error"), 'errors');
|
|
||||||
else
|
|
||||||
setEventMessage($langs->trans("SetupSaved"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -259,16 +254,16 @@ foreach ($dirmodels as $reldir)
|
|||||||
{
|
{
|
||||||
$file = substr($file, 0, dol_strlen($file)-4);
|
$file = substr($file, 0, dol_strlen($file)-4);
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.'.php';
|
require_once $dir.$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;
|
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled())
|
||||||
{
|
{
|
||||||
|
// 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;
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
|
print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
|
||||||
print '<td>';
|
print '<td>';
|
||||||
@ -278,7 +273,9 @@ foreach ($dirmodels as $reldir)
|
|||||||
// Show example of numbering module
|
// Show example of numbering module
|
||||||
print '<td nowrap="nowrap">';
|
print '<td nowrap="nowrap">';
|
||||||
$tmp=$module->getExample();
|
$tmp=$module->getExample();
|
||||||
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
|
if (preg_match('/^Error/',$tmp)) {
|
||||||
|
$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||||
|
}
|
||||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||||
else print $tmp;
|
else print $tmp;
|
||||||
print '</td>'."\n";
|
print '</td>'."\n";
|
||||||
@ -333,7 +330,7 @@ print '</table><br>';
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modeles de documents
|
* Documents models for Sendings Receipt
|
||||||
*/
|
*/
|
||||||
print_titre($langs->trans("SendingsReceiptModel"));
|
print_titre($langs->trans("SendingsReceiptModel"));
|
||||||
|
|
||||||
|
|||||||
@ -54,9 +54,9 @@ $specimenthirdparty->initAsSpecimen();
|
|||||||
if ($action == 'updateMask')
|
if ($action == 'updateMask')
|
||||||
{
|
{
|
||||||
$maskconstorder=GETPOST('maskconstorder','alpha');
|
$maskconstorder=GETPOST('maskconstorder','alpha');
|
||||||
$maskorder=GETPOST('maskorder','alpha');
|
$maskvalue=GETPOST('maskvalue','alpha');
|
||||||
|
|
||||||
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
|
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskvalue,'chaine',0,'',$conf->entity);
|
||||||
|
|
||||||
if (! $res > 0) $error++;
|
if (! $res > 0) $error++;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ if ($action == 'updateMask')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'specimen') // For orders
|
else if ($action == 'specimen') // For orders
|
||||||
{
|
{
|
||||||
$modele=GETPOST('module','alpha');
|
$modele=GETPOST('module','alpha');
|
||||||
|
|
||||||
@ -116,74 +116,40 @@ if ($action == 'specimen') // For orders
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set')
|
// Activate a model
|
||||||
|
else if ($action == 'set')
|
||||||
{
|
{
|
||||||
$label = GETPOST('label','alpha');
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
$scandir = GETPOST('scandir','alpha');
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
|
|
||||||
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
|
|
||||||
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
|
|
||||||
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
|
|
||||||
$sql.= ")";
|
|
||||||
$res=$db->query($sql);
|
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
// else dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'del')
|
else if ($action == 'del')
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
$ret = delDocumentModel($value, $type);
|
||||||
$sql.= " WHERE nom = '".$value."'";
|
if ($ret > 0)
|
||||||
$sql.= " AND type = '".$type."'";
|
{
|
||||||
$sql.= " AND entity = ".$conf->entity;
|
if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_SUPPLIER_ADDON_PDF',$conf->entity);
|
||||||
$db->query($sql);
|
}
|
||||||
if ($res)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
// else dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setdoc')
|
// Set default model
|
||||||
|
else if ($action == 'setdoc')
|
||||||
{
|
{
|
||||||
$label = GETPOST('label','alpha');
|
if (dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
||||||
$scandir = GETPOST('scandir','alpha');
|
{
|
||||||
|
// La constante qui a ete lue en avant du nouveau set
|
||||||
|
// on passe donc par une variable pour avoir un affichage coherent
|
||||||
|
$conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
|
||||||
|
}
|
||||||
|
|
||||||
$db->begin();
|
// On active le modele
|
||||||
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
if ($ret > 0)
|
||||||
{
|
{
|
||||||
$conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On active le modele
|
|
||||||
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
|
|
||||||
$sql_del.= " WHERE nom = '".$db->escape($value)."'";
|
|
||||||
$sql_del.= " AND type = '".$type."'";
|
|
||||||
$sql_del.= " AND entity = ".$conf->entity;
|
|
||||||
$result1=$db->query($sql_del);
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
|
|
||||||
$sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
|
|
||||||
$sql.= ($label?"'".$db->escape($label)."'":'null').", ";
|
|
||||||
$sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
|
|
||||||
$sql.= ")";
|
|
||||||
$result2=$db->query($sql);
|
|
||||||
if ($result1 && $result2)
|
|
||||||
{
|
|
||||||
$db->commit();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$db->rollback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'setmod')
|
else if ($action == 'setmod')
|
||||||
{
|
{
|
||||||
// TODO Verifier si module numerotation choisi peut etre active
|
// TODO Verifier si module numerotation choisi peut etre active
|
||||||
// par appel methode canBeActivated
|
// par appel methode canBeActivated
|
||||||
@ -191,13 +157,13 @@ if ($action == 'setmod')
|
|||||||
dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
|
dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'addcat')
|
else if ($action == 'addcat')
|
||||||
{
|
{
|
||||||
$fourn = new Fournisseur($db);
|
$fourn = new Fournisseur($db);
|
||||||
$fourn->CreateCategory($user,$_POST["cat"]);
|
$fourn->CreateCategory($user,$_POST["cat"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT')
|
else if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT')
|
||||||
{
|
{
|
||||||
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string
|
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string
|
||||||
|
|
||||||
@ -352,10 +318,8 @@ foreach ($dirmodels as $reldir)
|
|||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Modeles documents for supplier orders
|
* Documents models for supplier orders
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print_titre($langs->trans("OrdersModelModule"));
|
print_titre($langs->trans("OrdersModelModule"));
|
||||||
@ -396,17 +360,14 @@ print '</tr>'."\n";
|
|||||||
|
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
|
$var=true;
|
||||||
foreach ($dirmodels as $reldir)
|
foreach ($dirmodels as $reldir)
|
||||||
{
|
{
|
||||||
$dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
|
$dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
|
||||||
|
|
||||||
if (is_dir($dir))
|
if (is_dir($dir))
|
||||||
{
|
{
|
||||||
$var=true;
|
|
||||||
|
|
||||||
$handle=opendir($dir);
|
$handle=opendir($dir);
|
||||||
|
|
||||||
|
|
||||||
if (is_resource($handle))
|
if (is_resource($handle))
|
||||||
{
|
{
|
||||||
while (($file = readdir($handle))!==false)
|
while (($file = readdir($handle))!==false)
|
||||||
@ -448,7 +409,7 @@ foreach ($dirmodels as $reldir)
|
|||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defaut
|
// Default
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name")
|
if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name")
|
||||||
{
|
{
|
||||||
@ -485,6 +446,12 @@ foreach ($dirmodels as $reldir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table><br/>';
|
print '</table><br/>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Other options
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
print_titre($langs->trans("OtherOptions"));
|
print_titre($langs->trans("OtherOptions"));
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user