*
* 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
@@ -100,7 +100,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
-$taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 6, 24, 0, 29, 0, 33, 34, 32, 28, 17, 35, 36, 0, 10, 23, 12, 13, 7, 0, 14, 0, 22, 20, 18, 21, 41, 0, 37, 42, 0, 43, 0, 25, 0);
+$taborder = array(9, 15, 30, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 6, 24, 0, 29, 0, 33, 34, 32, 28, 17, 35, 36, 0, 10, 23, 12, 13, 7, 0, 14, 0, 22, 20, 18, 21, 41, 0, 37, 42, 0, 43, 0, 25, 0, 44, 0);
// Name of SQL tables of dictionaries
$tabname = array();
@@ -147,6 +147,7 @@ $tabname[40] = MAIN_DB_PREFIX."c_stcommcontact";
$tabname[41] = MAIN_DB_PREFIX."c_transport_mode";
$tabname[42] = MAIN_DB_PREFIX."c_product_nature";
$tabname[43] = MAIN_DB_PREFIX."c_productbatch_qcstatus";
+$tabname[44] = MAIN_DB_PREFIX."c_asset_disposal_type";
// Dictionary labels
$tablib = array();
@@ -193,6 +194,7 @@ $tablib[40] = "DictionaryProspectContactStatus";
$tablib[41] = "DictionaryTransportMode";
$tablib[42] = "DictionaryProductNature";
$tablib[43] = "DictionaryBatchStatus";
+$tablib[44] = "DictionaryAssetDisposalType";
// Requests to extract data
$tabsql = array();
@@ -223,7 +225,7 @@ $tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFI
$tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity = ".getEntity($tabname[25]);
//$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
$tabsql[27] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcomm";
-$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
+$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
$tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
$tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
//$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s";
@@ -239,6 +241,7 @@ $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN
$tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode";
$tabsql[42] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_product_nature";
$tabsql[43] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus";
+$tabsql[44] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_asset_disposal_type";
// Criteria to sort dictionaries
$tabsqlsort = array();
@@ -285,6 +288,7 @@ $tabsqlsort[40] = "code ASC";
$tabsqlsort[41] = "code ASC";
$tabsqlsort[42] = "code ASC";
$tabsqlsort[43] = "code ASC";
+$tabsqlsort[44] = "code ASC";
// Field names in select result for dictionary display
$tabfield = array();
@@ -315,7 +319,7 @@ $tabfield[24] = "code,label";
$tabfield[25] = "code,label";
//$tabfield[26]= "code,label,short_label";
$tabfield[27] = "code,libelle,picto";
-$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country";
+$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative";
$tabfield[29] = "code,label,percent,position";
$tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
//$tabfield[31]= "pcg_version,label";
@@ -331,6 +335,7 @@ $tabfield[40] = "code,libelle,picto";
$tabfield[41] = "code,label";
$tabfield[42] = "code,label";
$tabfield[43] = "code,label";
+$tabfield[44] = "code,label";
// Edit field names for editing a record
$tabfieldvalue = array();
@@ -361,7 +366,7 @@ $tabfieldvalue[24] = "code,label";
$tabfieldvalue[25] = "code,label";
//$tabfieldvalue[26]= "code,label,short_label";
$tabfieldvalue[27] = "code,libelle,picto";
-$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country";
+$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative";
$tabfieldvalue[29] = "code,label,percent,position";
$tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
//$tabfieldvalue[31]= "pcg_version,label";
@@ -377,6 +382,7 @@ $tabfieldvalue[40] = "code,libelle,picto";
$tabfieldvalue[41] = "code,label";
$tabfieldvalue[42] = "code,label";
$tabfieldvalue[43] = "code,label";
+$tabfieldvalue[44] = "code,label";
// Field names in the table for inserting a record
$tabfieldinsert = array();
@@ -407,7 +413,7 @@ $tabfieldinsert[24] = "code,label";
$tabfieldinsert[25] = "code,label";
//$tabfieldinsert[26]= "code,label,short_label";
$tabfieldinsert[27] = "code,libelle,picto";
-$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country";
+$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative";
$tabfieldinsert[29] = "code,label,percent,position";
$tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
//$tabfieldinsert[31]= "pcg_version,label";
@@ -424,6 +430,7 @@ $tabfieldinsert[40] = "code,libelle,picto";
$tabfieldinsert[41] = "code,label";
$tabfieldinsert[42] = "code,label";
$tabfieldinsert[43] = "code,label";
+$tabfieldinsert[44] = "code,label";
// Rowid name of field depending if field is autoincrement on or off..
// Use "" if id field is "rowid" and has autoincrement on
@@ -472,6 +479,7 @@ $tabrowid[40] = "id";
$tabrowid[41] = "";
$tabrowid[42] = "rowid";
$tabrowid[43] = "rowid";
+$tabrowid[44] = "rowid";
// Condition to show dictionary in setup page
$tabcond = array();
@@ -518,6 +526,7 @@ $tabcond[40] = (!empty($conf->societe->enabled) && !empty($conf->global->THIRDPA
$tabcond[41] = !empty($conf->intracommreport->enabled);
$tabcond[42] = !empty($conf->product->enabled);
$tabcond[43] = !empty($conf->product->enabled) && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2;
+$tabcond[44] = !empty($conf->asset->enabled);
// List of help for fields
$tabhelp = array();
@@ -564,6 +573,7 @@ $tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->tra
$tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[42] = array('code'=>$langs->trans("EnterAnyCode"));
$tabhelp[43] = array('code'=>$langs->trans("EnterAnyCode"));
+$tabhelp[44] = array('code'=>$langs->trans("EnterAnyCode"));
// Table to store complete informations (will replace all other table). Key is table name.
$tabcomplete = array(
@@ -609,6 +619,7 @@ $tabcomplete = array(
'c_stcommcontact'=>array('picto'=>'company'),
'c_product_nature'=>array('picto'=>'product'),
'c_productbatch_qcstatus'=>array('picto'=>'lot'),
+ 'c_asset_disposal_type'=>array('picto'=>'asset'),
);
@@ -706,19 +717,19 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
continue; // For some pages, country is not mandatory
}
// Discard check of mandatory fiedls for other fields
- if ($value == 'localtax1' && empty($_POST['localtax1_type'])) {
+ if ($value == 'localtax1' && !GETPOST('localtax1_type')) {
continue;
}
- if ($value == 'localtax2' && empty($_POST['localtax2_type'])) {
+ if ($value == 'localtax2' && !GETPOST('localtax2_type')) {
continue;
}
- if ($value == 'color' && empty($_POST['color'])) {
+ if ($value == 'color' && !GETPOST('color')) {
continue;
}
- if ($value == 'formula' && empty($_POST['formula'])) {
+ if ($value == 'formula' && !GETPOST('formula')) {
continue;
}
- if ($value == 'dayrule' && empty($_POST['dayrule'])) {
+ if ($value == 'dayrule' && !GETPOST('dayrule')) {
continue;
}
if ($value == 'sortorder') {
@@ -794,11 +805,6 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
$ok = 0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
- /*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
- {
- $ok = 0;
- $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
';
- }*/
}
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) {
if (in_array($tablib[$id], array('DictionaryCompanyType', 'DictionaryHolidayTypes'))) { // Field country is no mandatory for such dictionaries
@@ -830,7 +836,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
$_POST["accountancy_code_buy"] = ''; // If empty, we force to null
}
if ($id == 10 && GETPOSTISSET("code")) { // Spaces are not allowed into code for tax dictionary
- $_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', $_POST["code"]);
+ $_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', GETPOST("code"));
}
// If check ok and action add, add the line
@@ -883,7 +889,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
if ($keycode == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
$sql .= (int) GETPOST('position', 'int');
- } elseif ($_POST[$keycode] == '' && !($keycode == 'code' && $id == 10)) {
+ } elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) {
$sql .= "null"; // For vat, we want/accept code = ''
} elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
@@ -952,7 +958,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
$sql .= $field."=";
if ($listfieldvalue[$i] == 'sortorder') { // For column name 'sortorder', we use the field name 'position'
$sql .= (int) GETPOST('position', 'int');
- } elseif ($_POST[$keycode] == '' && !($keycode == 'code' && $id == 10)) {
+ } elseif (GETPOST($keycode) == '' && !($keycode == 'code' && $id == 10)) {
$sql .= "null"; // For vat, we want/accept code = ''
} elseif ($keycode == 'content') {
$sql .= "'".$db->escape(GETPOST($keycode, 'restricthtml'))."'";
@@ -1418,6 +1424,9 @@ if ($id) {
if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') {
$valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center';
}
+ if ($value == 'block_if_negative') {
+ $valuetoshow = $langs->trans('BlockHolidayIfNegative');
+ }
if ($id == 2) { // Special case for state page
if ($value == 'region_id') {
@@ -1764,6 +1773,9 @@ if ($id) {
if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') {
$valuetoshow = $langs->trans('TicketGroupIsPublic'); $cssprefix = 'center ';
}
+ if ($value == 'block_if_negative') {
+ $valuetoshow = $langs->trans('BlockHolidayIfNegative');
+ }
if ($value == 'region_id' || $value == 'country_id') {
$showfield = 0;
@@ -1981,8 +1993,9 @@ if ($id) {
}
}
} elseif ($value == 'fk_c_exp_tax_cat') {
- $valuetoshow = getDictionaryValue(MAIN_DB_PREFIX.'c_exp_tax_cat', 'label', $valuetoshow);
- $valuetoshow = $langs->trans($valuetoshow);
+ $tmpid = $valuetoshow;
+ $valuetoshow = getDictionaryValue(MAIN_DB_PREFIX.'c_exp_tax_cat', 'label', $tmpid);
+ $valuetoshow = $langs->trans($valuetoshow ? $valuetoshow : $tmpid);
} elseif ($tabname[$id] == MAIN_DB_PREFIX.'c_exp_tax_cat') {
$valuetoshow = $langs->trans($valuetoshow);
} elseif ($value == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_units') {
@@ -1997,6 +2010,8 @@ if ($id) {
} elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_productbatch_qcstatus') {
$langs->load("productbatch");
$valuetoshow = $langs->trans($obj->{$value});
+ } elseif ($value == 'block_if_negative') {
+ $valuetoshow = yn($obj->{$value});
}
$class .= ($class ? ' ' : '').'tddict';
if ($value == 'note' && $id == 10) {
@@ -2379,6 +2394,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print '';
print $form->selectExpenseRanges($obj->fk_range);
print ' | ';
+ } elseif ($value == 'block_if_negative') {
+ print '';
+ print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1);
+ print ' | ';
} else {
$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
@@ -2408,6 +2427,31 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
$fieldValue = '0';
}
}
+
+ // Labels Length
+ $maxlength = '';
+ if (in_array($fieldlist[$field], array('libelle', 'label'))) {
+ switch ($tabname) {
+ case MAIN_DB_PREFIX . 'c_accounting_category':
+ case MAIN_DB_PREFIX . 'c_ecotaxe':
+ case MAIN_DB_PREFIX . 'c_email_senderprofile':
+ case MAIN_DB_PREFIX . 'c_forme_juridique':
+ case MAIN_DB_PREFIX . 'c_holiday_types':
+ case MAIN_DB_PREFIX . 'c_payment_term':
+ case MAIN_DB_PREFIX . 'c_transport_mode':
+ $maxlength = ' maxlength="255"';
+ break;
+ case MAIN_DB_PREFIX . 'c_email_templates':
+ $maxlength = ' maxlength="180"';
+ break;
+ case MAIN_DB_PREFIX . 'c_socialnetworks':
+ $maxlength = ' maxlength="150"';
+ break;
+ default:
+ $maxlength = ' maxlength="128"';
+ }
+ }
+
print '';
$transfound = 0;
$transkey = '';
@@ -2426,7 +2470,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
}
}
if (!$transfound) {
- print '';
+ print '';
} else {
print '';
}
diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php
index 8edc61bf255..904d10bff67 100644
--- a/htdocs/admin/eventorganization.php
+++ b/htdocs/admin/eventorganization.php
@@ -41,6 +41,8 @@ $backtopage = GETPOST('backtopage', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index 2d4736cc49d..12e0d0a6d01 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'shipping';
diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php
index 5b73d995b5c..fc63940f0b8 100644
--- a/htdocs/admin/expensereport.php
+++ b/htdocs/admin/expensereport.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'expensereport';
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index ae269492ddf..9eec54b03a7 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -42,6 +42,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'invoice';
diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php
index 91134671692..609a6605d1a 100644
--- a/htdocs/admin/facture_situation.php
+++ b/htdocs/admin/facture_situation.php
@@ -28,24 +28,93 @@
*/
require '../main.inc.php';
+
+// Libraries
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('situationinvoicesetup', 'globalsetup'));
+
+// Access control
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'invoice';
+$form = new Form($db);
+$formSetup = new FormSetup($db);
+
+
+// Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style
+$formSetup->newItem('INVOICE_USE_SITUATION')
+ ->setAsYesNo()
+ ->nameText = $langs->trans('UseSituationInvoices');
+
+$item = $formSetup->newItem('INVOICE_USE_SITUATION_CREDIT_NOTE')
+ ->setAsYesNo()
+ ->nameText = $langs->trans('UseSituationInvoicesCreditNote');
+
+//$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY')
+// ->setAsYesNo()
+// ->nameText = $langs->trans('Retainedwarranty');
+
+
+$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY');
+$item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty');
+
+$arrayAvailableType = array(
+ Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
+ Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
+);
+
+if ($action == 'edit') {
+ $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 1);
+} else {
+ $item->fieldOutputOverride= isset($arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY])?$arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY]:'';
+}
+
+//$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
+//$item->nameText = $langs->trans('RetainedwarrantyOnlyForSituation');
+
+$formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
+ ->setAsYesNo()
+ ->nameText = $langs->trans('RetainedwarrantyOnlyForSituationFinal');
+
+
+$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
+$item->nameText = $langs->trans('RetainedwarrantyDefaultPercent');
+$item->fieldAttr = array(
+ 'type' => 'number',
+ 'step' => '0.01',
+ 'min' => 0,
+ 'max' => 100
+);
+
+
+// Conditions paiements
+$item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
+$item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
+$form->load_cache_conditions_paiements();
+if (!empty($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID) && isset($form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'])) {
+ $item->fieldOutputOverride = $form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'];
+}
+$item->fieldInputOverride = $form->getSelectConditionsPaiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
+
/*
* Actions
@@ -67,7 +136,6 @@ llxHeader(
'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
);
-$form = new Form($db);
$linkback = ''.$langs->trans("BackToModuleList").'';
@@ -84,170 +152,25 @@ print ''.$langs->trans("InvoiceFirstSituationDesc").
* Numbering module
*/
-print '';
print dol_get_fiche_end();
// End of page
llxFooter();
$db->close();
-
-/**
- * Print an update button
- *
- * @return void
- */
-function _updateBtn()
-{
- global $langs;
- print ' ';
- print '';
- print ' ';
-}
-
-/**
- * Print a On/Off button
- *
- * @param string $confkey the conf key
- * @param bool $title Title of conf
- * @param string $desc Description
- *
- * @return void
- */
-function _printOnOff($confkey, $title = false, $desc = '')
-{
- global $langs;
-
- print '';
- print ''.($title ? $title : $langs->trans($confkey));
- if (!empty($desc)) {
- print ' '.$langs->trans($desc).'';
- }
- print ' | ';
- print ' | ';
- print '';
- print ajax_constantonoff($confkey);
- print ' | ';
-}
-
-
-/**
- * Print a form part
- *
- * @param string $confkey the conf key
- * @param bool $title Title of conf
- * @param string $desc Description of
- * @param array $metas html meta
- * @param string $type type of input textarea or input
- * @param bool $help help description
- *
- * @return void
- */
-function _printInputFormPart($confkey, $title = false, $desc = '', $metas = array(), $type = 'input', $help = false)
-{
- global $langs, $conf, $db, $inputCount;
-
- $inputCount = empty($inputCount) ? 1 : ($inputCount + 1);
- $form = new Form($db);
-
- $defaultMetas = array(
- 'name' => 'value'.$inputCount
- );
-
- if ($type != 'textarea') {
- $defaultMetas['type'] = 'text';
- $defaultMetas['value'] = $conf->global->{$confkey};
- }
-
-
- $metas = array_merge($defaultMetas, $metas);
- $metascompil = '';
- foreach ($metas as $key => $values) {
- $metascompil .= ' '.$key.'="'.$values.'" ';
- }
-
- print '';
- print '';
-
- if (!empty($help)) {
- print $form->textwithtooltip(($title ? $title : $langs->trans($confkey)), $langs->trans($help), 2, 1, img_help(1, ''));
- } else {
- print $title ? $title : $langs->trans($confkey);
- }
-
- if (!empty($desc)) {
- print ' '.$langs->trans($desc).'';
- }
-
- print ' | ';
- print ' | ';
- print '';
- print '';
- print '';
- if ($type == 'textarea') {
- print '';
- } elseif ($type == 'input') {
- print '';
- } else {
- // custom
- print $type;
- }
- print ' | ';
-}
diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index 4369bb9a2a7..c95f354a189 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'ficheinter';
diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php
index bfd7e22c461..c1755b17edf 100644
--- a/htdocs/admin/holiday.php
+++ b/htdocs/admin/holiday.php
@@ -39,6 +39,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'contract';
diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php
index 1ad84ce19ac..aea86069f4d 100644
--- a/htdocs/admin/hrm.php
+++ b/htdocs/admin/hrm.php
@@ -50,6 +50,8 @@ $backtopage = GETPOST('backtopage', 'alpha');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 697f8fa2130..2c997d746d9 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -5,6 +5,7 @@
* Copyright (C) 2016 Juanjo Menent
* Copyright (C) 2018 Ferran Marcet
* Copyright (C) 2021 Alexandre Spangaro
+ * Copyright (C) 2021 Anthony Berton
*
* 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
@@ -199,6 +200,20 @@ if ($action == 'update') {
} else {
dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity);
}
+
+ $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BTNACTION'), array()))));
+ if ($val == '') {
+ dolibarr_del_const($db, 'THEME_ELDY_BTNACTION', $conf->entity);
+ } else {
+ dolibarr_set_const($db, 'THEME_ELDY_BTNACTION', $val, 'chaine', 0, '', $conf->entity);
+ }
+
+ $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTBTNACTION'), array()))));
+ if ($val == '') {
+ dolibarr_del_const($db, 'THEME_ELDY_TEXTBTNACTION', $conf->entity);
+ } else {
+ dolibarr_set_const($db, 'THEME_ELDY_TEXTBTNACTION', $val, 'chaine', 0, '', $conf->entity);
+ }
}
if ($mode == 'dashboard') {
@@ -265,6 +280,10 @@ if ($action == 'update') {
$_SESSION["mainmenu"] = ""; // The menu manager may have changed
+ if (GETPOST('dol_resetcache')) {
+ dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity);
+ }
+
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".'&mode='.$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : ''));
exit;
}
@@ -294,6 +313,7 @@ print '';
print '';
print '';
print '';
+print '';
$head = ihm_prepare_head();
@@ -634,6 +654,7 @@ if ($mode == 'login') {
print '';
print '';
+print '';
print ' ';
print '';
diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php
index cd9d7b44074..37168baa3d4 100644
--- a/htdocs/admin/import.php
+++ b/htdocs/admin/import.php
@@ -41,6 +41,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
/*
* Actions
diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php
index 8d93c16741a..c2440bbb885 100644
--- a/htdocs/admin/knowledgemanagement.php
+++ b/htdocs/admin/knowledgemanagement.php
@@ -37,8 +37,9 @@ $langs->loadLangs(array("admin", "knowledgemanagement"));
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
-
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'knowledgemanagement';
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 41a436b70a8..fc8e24b9322 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -903,8 +903,8 @@ if ($action == 'edit') {
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
- $formmail->fromname = (GETPOSTISSET('fromname') ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
- $formmail->frommail = (GETPOSTISSET('frommail') ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+ $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
+ $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->fromid = $user->id;
$formmail->fromalsorobot = 1;
$formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
@@ -912,9 +912,9 @@ if ($action == 'edit') {
$formmail->withsubstit = 1;
$formmail->withfrom = 1;
$formmail->witherrorsto = 1;
- $formmail->withto = (!empty($_POST['sendto']) ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
- $formmail->withtocc = (!empty($_POST['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
- $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
+ $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
+ $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
+ $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
$formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
$formmail->withtopicreadonly = 0;
$formmail->withfile = 2;
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index fb3a1ccf702..476f15459cb 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -308,7 +308,7 @@ if (empty($reshook)) {
// Rename some POST variables into a generic name
if (GETPOST('actionmodify', 'alpha') && $value == 'topic') {
- $_POST['topic'] = $_POST['topic-'.$rowid];
+ $_POST['topic'] = GETPOST('topic-'.$rowid);
}
if ((!GETPOSTISSET($value) || GETPOST($value) == '' || GETPOST($value) == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') {
diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php
index 79c549c0609..481fcad212c 100644
--- a/htdocs/admin/mails_ticket.php
+++ b/htdocs/admin/mails_ticket.php
@@ -537,16 +537,16 @@ if ($action == 'edit') {
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
- $formmail->fromname = (GETPOSTISSET('fromname') ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
- $formmail->frommail = (GETPOSTISSET('frommail') ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+ $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM);
+ $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
$formmail->withfromreadonly = 0;
$formmail->withsubstit = 0;
$formmail->withfrom = 1;
$formmail->witherrorsto = 1;
- $formmail->withto = (!empty($_POST['sendto']) ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
- $formmail->withtocc = (!empty($_POST['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty
- $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty
+ $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1));
+ $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1);
+ $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1);
$formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test"));
$formmail->withtopicreadonly = 0;
$formmail->withfile = 2;
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index 02c46d8ca35..b3c3e5066c2 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -152,32 +152,32 @@ if ($action == 'add') {
$langs->load("errors");
$error = 0;
- if (!$error && !$_POST['menu_handler']) {
+ if (!$error && !GETPOST('menu_handler')) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("MenuHandler")), null, 'errors');
$action = 'create';
$error++;
}
- if (!$error && !$_POST['type']) {
+ if (!$error && !GETPOST('type')) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
$action = 'create';
$error++;
}
- if (!$error && !$_POST['url']) {
+ if (!$error && !GETPOST('url')) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("URL")), null, 'errors');
$action = 'create';
$error++;
}
- if (!$error && !$_POST['titre']) {
+ if (!$error && !GETPOST('titre')) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
$action = 'create';
$error++;
}
- if (!$error && $_POST['menuId'] && $_POST['type'] == 'top') {
+ if (!$error && GETPOST('menuId') && GETPOST('type') == 'top') {
setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
$action = 'create';
$error++;
}
- if (!$error && !$_POST['menuId'] && $_POST['type'] == 'left') {
+ if (!$error && !GETPOST('menuId') && GETPOST('type') == 'left') {
setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
$action = 'create';
$error++;
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index 29d2335a0f9..4ad384233d8 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -48,7 +48,6 @@ if (empty($mode)) {
$mode = 'common';
}
$action = GETPOST('action', 'aZ09');
-//var_dump($_POST);exit;
$value = GETPOST('value', 'alpha');
$page_y = GETPOST('page_y', 'int');
$search_keyword = GETPOST('search_keyword', 'alpha');
diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php
index 54efdc4df19..fac6a3f3d41 100644
--- a/htdocs/admin/mrp.php
+++ b/htdocs/admin/mrp.php
@@ -37,6 +37,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'mrp';
diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php
index 9bf5be2c294..a0d82d1d6bd 100644
--- a/htdocs/admin/oauth.php
+++ b/htdocs/admin/oauth.php
@@ -27,6 +27,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php';
+// $supportedoauth2array is defined into oauth.lib.php
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
@@ -96,10 +97,12 @@ print '';
$i = 0;
-// $list is defined into oauth.lib.php
+// $list is defined into oauth.lib.php to the list of supporter OAuth providers.
foreach ($list as $key) {
$supported = 0;
- if (in_array($key[0], array_keys($supportedoauth2array))) {
+ $keyforsupportedoauth2array = $key[0];
+
+ if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) {
$supported = 1;
}
if (!$supported) {
@@ -110,20 +113,23 @@ foreach ($list as $key) {
print '';
// Api Name
- $label = $langs->trans($key[0]);
- print '| '.$label.' | ';
+ $label = $langs->trans($keyforsupportedoauth2array);
print '';
- if (!empty($key[3])) {
- print $langs->trans($key[3]);
+ print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
+ print $label;
+ print ' | ';
+ print '';
+ if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforapp'])) {
+ print $langs->trans($supportedoauth2array[$keyforsupportedoauth2array]['urlforapp']);
}
print ' | ';
print ' ';
if ($supported) {
- $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$key[0]].'_oauthcallback.php';
+ $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
print '';
print '| '.$langs->trans("UseTheFollowingUrlAsRedirectURI").' | ';
- print '';
+ print ' | ';
print ' | ';
} else {
print '';
diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php
index 8697b400a2b..73a9139f856 100644
--- a/htdocs/admin/oauthlogintokens.php
+++ b/htdocs/admin/oauthlogintokens.php
@@ -25,17 +25,13 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list
+require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list and $supportedoauth2array
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
use OAuth\Common\Storage\DoliStorage;
// Load translation files required by the page
$langs->loadLangs(array('admin', 'printing', 'oauth'));
-if (!$user->admin) {
- accessforbidden();
-}
-
$action = GETPOST('action', 'aZ09');
$mode = GETPOST('mode', 'alpha');
$value = GETPOST('value', 'alpha');
@@ -50,6 +46,10 @@ if (!$mode) {
$mode = 'setup';
}
+if (!$user->admin) {
+ accessforbidden();
+}
+
/*
* Action
@@ -122,7 +122,7 @@ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domai
$form = new Form($db);
-llxHeader('', $langs->trans("PrintingSetup"));
+llxHeader('', $langs->trans("TokenManager"));
$linkback = ''.$langs->trans("BackToModuleList").'';
print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
@@ -140,7 +140,9 @@ if ($mode == 'setup' && $user->admin) {
foreach ($list as $key) {
$supported = 0;
- if (in_array($key[0], array_keys($supportedoauth2array))) {
+ $keyforsupportedoauth2array = $key[0];
+
+ if (in_array($keyforsupportedoauth2array, array_keys($supportedoauth2array))) {
$supported = 1;
}
if (!$supported) {
@@ -148,34 +150,44 @@ if ($mode == 'setup' && $user->admin) {
}
- $OAUTH_SERVICENAME = 'Unknown';
- if ($key[0] == 'OAUTH_GITHUB_NAME') {
- $OAUTH_SERVICENAME = 'GitHub';
+ $OAUTH_SERVICENAME = empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'];
+
+ // Define $shortscope, $urltorenew, $urltodelete, $urltocheckperms
+ // TODO Use array $supportedoauth2array
+ if ($keyforsupportedoauth2array == 'OAUTH_GITHUB_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect.
$shortscope = 'user,public_repo';
$urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/';
- } elseif ($key[0] == 'OAUTH_GOOGLE_NAME') {
- $OAUTH_SERVICENAME = 'Google';
+ } elseif ($keyforsupportedoauth2array == 'OAUTH_GOOGLE_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
- // We pass this param list in to 'state' because we need it before and after the redirect.
- $shortscope = 'userinfo_email,userinfo_profile,cloud_print';
- if (!empty($conf->global->OAUTH_GSUITE)) {
+ // List of scopes for Google are here: https://developers.google.com/identity/protocols/oauth2/scopes
+ // We pass this key list into the param 'state' because we need it before and after the redirect.
+ $shortscope = 'userinfo_email,userinfo_profile';
+ $shortscope .= ',openid,email,profile'; // For openid connect
+ if (!empty($conf->printing->enabled)) {
+ $shortscope .= ',cloud_print';
+ }
+ if (!empty($conf->global->OAUTH_GOOGLE_GSUITE)) {
$shortscope .= ',admin_directory_user';
}
- //$scope.=',gmail_full';
- $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ if (!empty($conf->global->OAUTH_GOOGLE_GMAIL)) {
+ $shortscope.=',gmail_full';
+ }
+
+ $oauthstateanticsrf = bin2hex(random_bytes(128/8));
+ $_SESSION['oauthstateanticsrf'] = $shortscope.'-'.$oauthstateanticsrf;
+
+ $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions';
- } elseif ($key[0] == 'OAUTH_STRIPE_TEST_NAME') {
- $OAUTH_SERVICENAME = 'StripeTest';
+ } elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_TEST_NAME') {
$urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
- } elseif ($key[0] == 'OAUTH_STRIPE_LIVE_NAME') {
- $OAUTH_SERVICENAME = 'StripeLive';
+ } elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_LIVE_NAME') {
$urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
@@ -230,11 +242,14 @@ if ($mode == 'setup' && $user->admin) {
print '';
print '';
- print '';
+ print ' ';
print ' '."\n";
print '';
- print '| '.$langs->trans($key[0]).' | ';
+ print '';
+ print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
+ print $langs->trans($keyforsupportedoauth2array);
+ print ' | ';
print ' | ';
print ' | ';
print " \n";
@@ -244,7 +259,7 @@ if ($mode == 'setup' && $user->admin) {
//var_dump($key);
print $langs->trans("OAuthIDSecret").'';
print '';
- print $langs->trans("SeePreviousTab");
+ print ''.$langs->trans("SeePreviousTab").'';
print ' | ';
print '';
print ' | ';
@@ -259,7 +274,7 @@ if ($mode == 'setup' && $user->admin) {
if (is_object($tokenobj)) {
print $langs->trans("HasAccessToken");
} else {
- print $langs->trans("NoAccessToken");
+ print ''.$langs->trans("NoAccessToken").'';
}
print '';
print '';
@@ -346,7 +361,7 @@ if ($mode == 'setup' && $user->admin) {
if ($mode == 'test' && $user->admin) {
print $langs->trans('PrintTestDesc'.$driver)."
\n";
- print '';
+ print ' ';
print ' ';
if (!empty($driver)) {
require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index 33f8f5b87f2..fd8377b0a27 100644
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -96,9 +96,9 @@ if ($action == 'update') {
dolibarr_set_const($db, "MAIN_PDF_NO_RECIPENT_FRAME", GETPOST("MAIN_PDF_NO_RECIPENT_FRAME"), 'chaine', 0, '', $conf->entity);
}
- if (GETPOSTISSET('MAIN_PDF_HIDE_SENDER_NAME')) {
+ /*if (GETPOSTISSET('MAIN_PDF_HIDE_SENDER_NAME')) {
dolibarr_set_const($db, "MAIN_PDF_HIDE_SENDER_NAME", GETPOST("MAIN_PDF_HIDE_SENDER_NAME"), 'chaine', 0, '', $conf->entity);
- }
+ }*/
if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity);
@@ -307,6 +307,18 @@ print '';
print ' ';
print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ';
+// Show sender name
+
+/* Set option as hidden because no need of this for 99.99% of users.
+print '| '.$langs->trans("MAIN_PDF_HIDE_SENDER_NAME").' | ';
+if ($conf->use_javascript_ajax) {
+ print ajax_constantonoff('MAIN_PDF_HIDE_SENDER_NAME');
+} else {
+ print $form->selectyesno('MAIN_PDF_HIDE_SENDER_NAME', (!empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) ? $conf->global->MAIN_PDF_HIDE_SENDER_NAME : 0, 1);
+}
+print ' | ';
+*/
+
// Hide VAT Intra on address
print '| '.$langs->trans("ShowVATIntaInAddress").' | ';
@@ -358,16 +370,6 @@ if ($conf->use_javascript_ajax) {
print $form->selectarray("MAIN_PDF_NO_RECIPENT_FRAME", $arrval, $conf->global->MAIN_PDF_NO_RECIPENT_FRAME);
}
-// Show sender name
-
-print ' | | '.$langs->trans("MAIN_PDF_HIDE_SENDER_NAME").' | ';
-if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('MAIN_PDF_HIDE_SENDER_NAME');
-} else {
- print $form->selectyesno('MAIN_PDF_HIDE_SENDER_NAME', (!empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) ? $conf->global->MAIN_PDF_HIDE_SENDER_NAME : 0, 1);
-}
-print ' | ';
-
//Invert sender and recipient
print '| '.$langs->trans("SwapSenderAndRecipientOnPDF").' | ';
@@ -506,22 +508,6 @@ if ($conf->use_javascript_ajax) {
}
print ' | ';
-print '| '.$langs->trans("BoldLabelOnPDF").' | ';
-if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('PDF_BOLD_PRODUCT_LABEL');
-} else {
- print $form->selectyesno('PDF_BOLD_PRODUCT_LABEL', (!empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) ? $conf->global->PDF_BOLD_PRODUCT_LABEL : 0, 1);
-}
-print ' | ';
-
-print '| '.$langs->trans("BoldRefAndPeriodOnPDF").' | ';
-if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('PDF_BOLD_PRODUCT_REF_AND_PERIOD');
-} else {
- print $form->selectyesno('PDF_BOLD_PRODUCT_REF_AND_PERIOD', (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) ? $conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD : 0, 1);
-}
-print ' | ';
-
// Desc
print '| '.$langs->trans("HideDescOnPDF").' | ';
@@ -542,6 +528,26 @@ if ($conf->use_javascript_ajax) {
}
print ' | ';
+// Swicth in Bold
+
+print '| '.$langs->trans("BoldLabelOnPDF").' | ';
+if ($conf->use_javascript_ajax) {
+ print ajax_constantonoff('PDF_BOLD_PRODUCT_LABEL');
+} else {
+ print $form->selectyesno('PDF_BOLD_PRODUCT_LABEL', (!empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) ? $conf->global->PDF_BOLD_PRODUCT_LABEL : 0, 1);
+}
+print ' | ';
+
+// Swicth in Bold
+
+print '| '.$langs->trans("BoldRefAndPeriodOnPDF").' | ';
+if ($conf->use_javascript_ajax) {
+ print ajax_constantonoff('PDF_BOLD_PRODUCT_REF_AND_PERIOD');
+} else {
+ print $form->selectyesno('PDF_BOLD_PRODUCT_REF_AND_PERIOD', (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) ? $conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD : 0, 1);
+}
+print ' | ';
+
// SHOW_SUBPRODUCT_REF_IN_PDF - Option to show the detail of product ref for kits.
print '| '.$langs->trans("SHOW_SUBPRODUCT_REF_IN_PDF", $langs->transnoentitiesnoconv("AssociatedProductsAbility"), $langs->transnoentitiesnoconv("Products")).' | ';
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index 22ce045a7ab..6384c561967 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'propal';
diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php
index 218cc1ef853..26300ece329 100644
--- a/htdocs/admin/reception_setup.php
+++ b/htdocs/admin/reception_setup.php
@@ -36,6 +36,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'reception';
diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php
index 05abf8c3995..19a94d05dd8 100644
--- a/htdocs/admin/sms.php
+++ b/htdocs/admin/sms.php
@@ -62,7 +62,7 @@ if ($action == 'update' && !$cancel) {
// Send sms
-if ($action == 'send' && !$_POST['cancel']) {
+if ($action == 'send' && !$cancel) {
$error = 0;
$smsfrom = '';
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index 808528cdc0a..0da79845d14 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -43,6 +43,8 @@ if (!$user->admin) {
$type = GETPOST('type', 'alpha');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$action = GETPOST('action', 'aZ09');
$scandir = GETPOST('scan_dir', 'alpha');
diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php
index b31e4c9a433..a41f9fdf80c 100644
--- a/htdocs/admin/supplier_payment.php
+++ b/htdocs/admin/supplier_payment.php
@@ -37,6 +37,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scandir', 'alpha');
$type = 'supplier_payment';
diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php
index 6e3f190aeb6..9bd684afb22 100644
--- a/htdocs/admin/supplier_proposal.php
+++ b/htdocs/admin/supplier_proposal.php
@@ -38,6 +38,8 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'supplier_proposal';
diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php
index 9321fa11c12..c48acebe140 100644
--- a/htdocs/admin/system/security.php
+++ b/htdocs/admin/system/security.php
@@ -99,6 +99,7 @@ if (!ini_get('session.cookie_samesite') || ini_get('session.cookie_samesite') ==
}
print " \n";
print "PHP open_basedir = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0).' ('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("ARestrictedPath").', '.$langs->transnoentitiesnoconv("Example").': '.$_SERVER["DOCUMENT_ROOT"].','.DOL_DATA_ROOT).')')." \n";
+print "PHP short_open_tag = ".((empty(ini_get('short_open_tag')) || ini_get('short_open_tag') == 'Off') ? yn(0) : img_warning().' '.yn(0)).' ('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).')'." \n";
print "PHP allow_url_fopen = ".(ini_get('allow_url_fopen') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_fopen') : yn(0)).' ('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).") \n";
print "PHP allow_url_include = ".(ini_get('allow_url_include') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_include') : yn(0)).' ('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).") \n";
//print "PHP safe_mode = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0)).' '.$langs->trans("Deprecated")." (removed in PHP 5.4) \n";
diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php
index 03fd647dd29..c36f6ae1d1b 100644
--- a/htdocs/admin/ticket.php
+++ b/htdocs/admin/ticket.php
@@ -38,6 +38,8 @@ if (!$user->admin) {
// Parameters
$value = GETPOST('value', 'alpha');
$action = GETPOST('action', 'aZ09');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scandir', 'alpha');
$type = 'ticket';
@@ -141,6 +143,20 @@ if ($action == 'updateMask') {
}
}
+if ($action == 'setvarworkflow') {
+ $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity);
+ if (!($res > 0)) {
+ $error++;
+ }
+
+ $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
+ if (!($res > 0)) {
+ $error++;
+ }
+}
+
if ($action == 'setvarother') {
$param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
$res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
@@ -176,8 +192,14 @@ if ($action == 'setvarother') {
$error++;
}
- $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
- $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
+ $param_delay_first_response = GETPOST('delay_first_response', 'int');
+ $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity);
+ if (!($res > 0)) {
+ $error++;
+ }
+
+ $param_delay_between_responses = GETPOST('delay_between_responses', 'int');
+ $res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
@@ -465,7 +487,7 @@ print ' ';
if (!$conf->use_javascript_ajax) {
print ' | \n";
+// Auto mark ticket read when created from backoffice
+print '| '.$langs->trans("TicketsAutoReadTicket").' | ';
+print '';
+if ($conf->use_javascript_ajax) {
+ print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND');
+} else {
+ $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+ print $form->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
+}
+print ' | ';
+print '';
+print $form->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help');
+print ' | ';
+print ' ';
+
// Auto assign ticket at user who created it
-print '| '.$langs->trans("TicketsAutoAssignTicket").' | ';
+print ' ';
+print '| '.$langs->trans("TicketsAutoAssignTicket").' | ';
print '';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
@@ -492,12 +530,41 @@ print $form->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1,
print ' | ';
print ' ';
-print ' ';
-
if (!$conf->use_javascript_ajax) {
print '';
}
+// Define wanted maximum time elapsed before answers to tickets
+print ' ';
+
+print ' ';
+
+
// Admin var of module
print load_fiche_titre($langs->trans("Notification"), '', '');
diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php
index 85ab0f0e9a8..53de8fe2502 100644
--- a/htdocs/admin/user.php
+++ b/htdocs/admin/user.php
@@ -43,9 +43,11 @@ $extrafields = new ExtraFields($db);
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
+
$scandir = GETPOST('scandir', 'alpha');
$type = 'user';
diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php
index 3319ab994a6..709b60068f7 100644
--- a/htdocs/admin/usergroup.php
+++ b/htdocs/admin/usergroup.php
@@ -42,6 +42,8 @@ $extrafields = new ExtraFields($db);
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
+
$type = 'group';
/*
diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php
index d1a24ff072c..b5098bfd3ce 100644
--- a/htdocs/admin/website.php
+++ b/htdocs/admin/website.php
@@ -198,15 +198,15 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($value == 'ref') {
- $_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]);
+ $_POST[$listfieldvalue[$i]] = strtolower(GETPOST($listfieldvalue[$i]));
}
if ($i) {
$sql .= ",";
}
- if ($_POST[$listfieldvalue[$i]] == '') {
+ if (GETPOST($listfieldvalue[$i]) == '') {
$sql .= "null";
} else {
- $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+ $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
}
$i++;
}
@@ -259,7 +259,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
if ($_POST[$listfieldvalue[$i]] == '') {
$sql .= "null";
} else {
- $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+ $sql .= "'".$db->escape(GETPOST($listfieldvalue[$i]))."'";
}
$i++;
}
diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php
index e89cbb2fd41..58118827ed4 100644
--- a/htdocs/admin/workstation.php
+++ b/htdocs/admin/workstation.php
@@ -36,6 +36,7 @@ $langs->loadLangs(array("admin", "workstation"));
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
+$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
$value = GETPOST('value', 'alpha');
diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index 2a6b5f33a27..fa21c37649f 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -173,6 +173,7 @@ class DolibarrApi
unset($object->stats_mrptoproduce);
unset($object->element);
+ unset($object->element_for_permission);
unset($object->fk_element);
unset($object->table_element);
unset($object->table_element_line);
diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php
index 2ab8c7837ac..9c7cc01630d 100644
--- a/htdocs/api/class/api_setup.class.php
+++ b/htdocs/api/class/api_setup.class.php
@@ -209,7 +209,7 @@ class Setup extends DolibarrApi
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
- $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
@@ -239,7 +239,6 @@ class Setup extends DolibarrApi
return $list;
}
-
/**
* Get the list of states/provinces.
*
@@ -252,27 +251,34 @@ class Setup extends DolibarrApi
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
- * @param string $filter To filter the countries by name
+ * @param int $country To filter on country
+ * @param string $filter To filter the states by name
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
- * @return array List of countries
+ * @return array List of states
*
* @url GET dictionary/states
*
* @throws RestException
*/
- public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $sqlfilters = '')
+ public function getListOfStates($sortfield = "code_departement", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $filter = '', $sqlfilters = '')
{
$list = array();
// Note: The filter is not applied in the SQL request because it must
// be applied to the translated names, not to the names in database.
- $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t";
+ $sql = "SELECT t.rowid FROM ".MAIN_DB_PREFIX."c_departements as t";
+ if ($country) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as d ON t.fk_region = d.code_region";
+ }
$sql .= " WHERE 1 = 1";
+ if ($country) {
+ $sql .= " AND d.fk_pays = ".((int) $country);
+ }
// Add sql filters
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -373,7 +379,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -665,7 +671,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -729,7 +735,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -797,7 +803,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -860,7 +866,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -933,7 +939,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1004,7 +1010,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1078,7 +1084,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1143,9 +1149,9 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(400, 'error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
- $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
@@ -1202,9 +1208,9 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(400, 'error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
- $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
@@ -1261,7 +1267,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1301,7 +1307,7 @@ class Setup extends DolibarrApi
* @param string $sortorder Sort order
* @param int $limit Number of items per page
* @param int $page Page number (starting from zero)
- * @param string $country To filter on country
+ * @param int $country To filter on country
* @param int $active Lega form is active or not {@min 0} {@max 1}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)"
* @return array List of legal form
@@ -1310,7 +1316,7 @@ class Setup extends DolibarrApi
*
* @throws RestException
*/
- public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = '', $active = 1, $sqlfilters = '')
+ public function getListOfLegalForm($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $country = 0, $active = 1, $sqlfilters = '')
{
$list = array();
@@ -1318,13 +1324,13 @@ class Setup extends DolibarrApi
$sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as t";
$sql .= " WHERE t.active = ".((int) $active);
if ($country) {
- $sql .= " AND t.fk_pays = '".$this->db->escape($country)."'";
+ $sql .= " AND t.fk_pays = ".((int) $country);
}
// Add sql filters
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1383,7 +1389,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1449,7 +1455,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1508,7 +1514,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1567,7 +1573,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
@@ -1628,7 +1634,7 @@ class Setup extends DolibarrApi
if ($sqlfilters) {
$errormessage = '';
if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage);
+ throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
diff --git a/htdocs/asset/accountancy_codes.php b/htdocs/asset/accountancy_codes.php
new file mode 100644
index 00000000000..431b4ba7c68
--- /dev/null
+++ b/htdocs/asset/accountancy_codes.php
@@ -0,0 +1,189 @@
+
+ * Copyright (C) 2018 Alexandre Spangaro
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/asset/accountancy_code.php
+ * \ingroup asset
+ * \brief Card with accountancy code on Asset
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT . '/core/lib/asset.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/asset/class/asset.class.php';
+require_once DOL_DOCUMENT_ROOT . '/asset/class/assetaccountancycodes.class.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("assets", "companies"));
+
+// Get parameters
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+
+// Initialize technical objects
+$object = new Asset($db);
+$assetaccountancycodes = new AssetAccountancyCodes($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->asset->dir_output . '/temp/massgeneration/' . $user->id;
+$hookmanager->initHooks(array('assetaccountancycodes', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+if ($id > 0 || !empty($ref)) {
+ $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id;
+}
+
+$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
+
+// Security check (enable the most restrictive one)
+if ($user->socid > 0) accessforbidden();
+$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
+restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
+if (empty($conf->asset->enabled)) accessforbidden();
+
+$result = $assetaccountancycodes->fetchAccountancyCodes($object->id);
+if ($result < 0) {
+ setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
+}
+
+
+/*
+ * Actions
+ */
+
+$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+if (empty($reshook)) {
+ $backurlforlist = DOL_URL_ROOT.'/asset/list.php';
+
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
+ $backtopage = $backurlforlist;
+ } else {
+ $backtopage = DOL_URL_ROOT.'/asset/accountancy_codes.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
+ }
+ }
+ }
+
+ if ($cancel) {
+ /*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
+ if (!empty($backtopageforcancel)) {
+ header("Location: ".$backtopageforcancel);
+ exit;
+ } elseif (!empty($backtopage)) {
+ header("Location: ".$backtopage);
+ exit;
+ }
+ $action = '';
+ }
+
+ if ($action == "update") {
+ $assetaccountancycodes->setAccountancyCodesFromPost();
+
+ $result = $assetaccountancycodes->updateAccountancyCodes($user, $object->id);
+ if ($result < 0) {
+ setEventMessages($assetaccountancycodes->error, $assetaccountancycodes->errors, 'errors');
+ $action = 'edit';
+ } else {
+ setEventMessage($langs->trans('RecordSaved'));
+ header("Location: " . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
+ exit;
+ }
+ }
+}
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$help_url = '';
+llxHeader('', $langs->trans('Asset'), $help_url);
+
+if ($id > 0 || !empty($ref)) {
+ $head = assetPrepareHead($object);
+ print dol_get_fiche_head($head, 'accountancy_codes', $langs->trans("Asset"), -1, $object->picto);
+
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = '' . $langs->trans("BackToList") . '';
+
+ $morehtmlref = '';
+ $morehtmlref .= ' ';
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+ print '';
+
+ if ($action == 'edit') {
+ print '';
+ } else {
+ include DOL_DOCUMENT_ROOT . '/asset/tpl/accountancy_codes_view.tpl.php';
+ }
+
+ print dol_get_fiche_end();
+
+ if ($action != 'edit') {
+ print '' . "\n";
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ }
+
+ if (empty($reshook)) {
+ if ($object->status == $object::STATUS_DRAFT/* && !empty($object->enabled_modes)*/) {
+ print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
+ }
+ }
+ print ' ' . "\n";
+ }
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/asset_extrafields.php
similarity index 56%
rename from htdocs/asset/admin/assets_type_extrafields.php
rename to htdocs/asset/admin/asset_extrafields.php
index 165361f7f57..a84d3bc2016 100644
--- a/htdocs/asset/admin/assets_type_extrafields.php
+++ b/htdocs/asset/admin/asset_extrafields.php
@@ -1,5 +1,11 @@
+/* Copyright (C) 2001-2002 Rodolphe Quiedeville
+ * Copyright (C) 2003 Jean-Louis Bergamo
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2018 Alexandre Spangaro
*
* 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
@@ -13,20 +19,20 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- * or see https://www.gnu.org/
*/
/**
- * \file htdocs/asset/admin/assets_type_extrafields.php
- * \ingroup asset
- * \brief Page to setup extra fields type of assets
+ * \file htdocs/asset/admin/asset_extrafields.php
+ * \ingroup asset
+ * \brief Page to setup extra fields of asset
*/
+
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('assets', 'admin'));
+$langs->loadLangs(array("assets", "admin", "companies"));
$extrafields = new ExtraFields($db);
$form = new Form($db);
@@ -40,7 +46,7 @@ foreach ($tmptype2label as $key => $val) {
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
-$elementtype = 'adherent_type'; //Must be the $table_element of the class that manage extrafield
+$elementtype = 'asset'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) {
accessforbidden();
@@ -59,38 +65,47 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
-$textobject = $langs->transnoentitiesnoconv("AssetsTypes");
+$help_url = '';
+$page_name = "AssetSetup";
+$textobject = $langs->transnoentitiesnoconv("Assets");
-llxHeader('', $langs->trans("AssetsSetup"));
-
-$linkback = ''.$langs->trans("BackToModuleList").'';
-print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup');
+llxHeader('', $langs->trans("AssetSetup"), $help_url);
-$head = asset_admin_prepare_head();
+$linkback = ''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
-print dol_get_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, 'generic');
+
+$head = assetAdminPrepareHead();
+
+print dol_get_fiche_head($head, 'asset_extrafields', $langs->trans($page_name), -1, 'asset');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
print dol_get_fiche_end();
+
// Buttons
if ($action != 'create' && $action != 'edit') {
print '";
}
-// Creation of an optional field
+
+/*
+ * Creation of an optional field
+ */
if ($action == 'create') {
- print " ";
+ print ' ';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
-// Edition of an optional field
+/*
+ * Edition of an optional field
+ */
if ($action == 'edit' && !empty($attrname)) {
print " ";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assetmodel_extrafields.php
similarity index 54%
rename from htdocs/asset/admin/assets_extrafields.php
rename to htdocs/asset/admin/assetmodel_extrafields.php
index 9a68f99fe06..387c43df635 100644
--- a/htdocs/asset/admin/assets_extrafields.php
+++ b/htdocs/asset/admin/assetmodel_extrafields.php
@@ -1,6 +1,11 @@
- * Copyright (C) 2018 Alexandre Spangaro
+/* Copyright (C) 2001-2002 Rodolphe Quiedeville
+ * Copyright (C) 2003 Jean-Louis Bergamo
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2018 Alexandre Spangaro
*
* 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
@@ -17,9 +22,9 @@
*/
/**
- * \file htdocs/asset/admin/assets_extrafields.php
+ * \file htdocs/asset/admin/assetmodel_extrafields.php
* \ingroup asset
- * \brief Page to setup extra fields of assets
+ * \brief Page to setup extra fields of asset model
*/
require '../../main.inc.php';
@@ -41,7 +46,7 @@ foreach ($tmptype2label as $key => $val) {
$action = GETPOST('action', 'aZ09');
$attrname = GETPOST('attrname', 'alpha');
-$elementtype = 'don'; //Must be the $table_element of the class that manage extrafield
+$elementtype = 'asset_model'; //Must be the $table_element of the class that manage extrafield
if (!$user->admin) {
accessforbidden();
@@ -60,17 +65,20 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
-$textobject = $langs->transnoentitiesnoconv("Assets");
+$help_url = '';
+$page_name = "AssetSetup";
+$textobject = $langs->transnoentitiesnoconv("AssetModels");
-llxHeader('', $langs->trans("AssetsSetup"));
-
-$linkback = ''.$langs->trans("BackToModuleList").'';
-print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup');
+llxHeader('', $langs->trans("AssetSetup"), $help_url);
-$head = asset_admin_prepare_head();
+$linkback = ''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
-print dol_get_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'generic');
+
+$head = assetAdminPrepareHead();
+
+print dol_get_fiche_head($head, 'assetmodel_extrafields', $langs->trans($page_name), -1, 'asset');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
@@ -80,29 +88,24 @@ print dol_get_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit') {
print '";
}
-/* ************************************************************************** */
-/* */
-/* Create optional field */
-/* */
-/* ************************************************************************** */
-
+/*
+ * Creation of an optional field
+ */
if ($action == 'create') {
- print " ";
+ print ' ';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
-/* ************************************************************************** */
-/* */
-/* Edit optional field */
-/* */
-/* ************************************************************************** */
+/*
+ * Edition of an optional field
+ */
if ($action == 'edit' && !empty($attrname)) {
print " ";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php
index a90c2b479c4..afa4777de3d 100644
--- a/htdocs/asset/admin/setup.php
+++ b/htdocs/asset/admin/setup.php
@@ -18,8 +18,8 @@
/**
* \file htdocs/asset/admin/setup.php
- * \ingroup assets
- * \brief Assets setup page.
+ * \ingroup asset
+ * \brief Asset setup page.
*/
require '../../main.inc.php';
@@ -40,30 +40,421 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
-$arrayofparameters = array('FIXEDASSETS_MYPARAM1'=>array('css'=>'minwidth200'), 'FIXEDASSETS_MYPARAM2'=>array('css'=>'minwidth500'));
+$value = GETPOST('value', 'alpha');
+$label = GETPOST('label', 'alpha');
+$scandir = GETPOST('scan_dir', 'alpha');
+$type = 'asset';
+
+$arrayofparameters = array(
+ 'ASSET_ACCOUNTANCY_CATEGORY'=>array('type'=>'accountancy_category', 'enabled'=>1),
+ 'ASSET_DEPRECIATION_DURATION_PER_YEAR'=>array('type'=>'string', 'css'=>'minwidth200', 'enabled'=>1),
+ //'ASSET_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
+ //'ASSET_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
+ //'ASSET_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
+ //'ASSET_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
+ //'ASSET_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
+ //'ASSET_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1),
+ //'ASSET_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
+);
+
+$error = 0;
+$setupnotempty = 0;
+
+$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
/*
* Actions
*/
-include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
+if ((float) DOL_VERSION >= 6) {
+ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
+}
+
+if ($action == 'updateMask') {
+ $maskconstorder = GETPOST('maskconstorder', 'alpha');
+ $maskorder = GETPOST('maskorder', 'alpha');
+
+ if ($maskconstorder) {
+ $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity);
+ if (!($res > 0)) {
+ $error++;
+ }
+ }
+
+ if (!$error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'errors');
+ }
+} elseif ($action == 'specimen') {
+ $modele = GETPOST('module', 'alpha');
+ $tmpobjectkey = GETPOST('object');
+
+ $tmpobject = new $tmpobjectkey($db);
+ $tmpobject->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/asset/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0);
+ if (file_exists($file)) {
+ $filefound = 1;
+ $classname = "pdf_".$modele;
+ break;
+ }
+ }
+
+ if ($filefound) {
+ require_once $file;
+
+ $module = new $classname($db);
+
+ if ($module->write_file($tmpobject, $langs) > 0) {
+ header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf");
+ return;
+ } else {
+ setEventMessages($module->error, null, 'errors');
+ dol_syslog($module->error, LOG_ERR);
+ }
+ } else {
+ setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
+ dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+ }
+} elseif ($action == 'setmod') {
+ // TODO Check if numbering module chosen can be activated by calling method canBeActivated
+ $tmpobjectkey = GETPOST('object');
+ if (!empty($tmpobjectkey)) {
+ $constforval = 'ASSET_'.strtoupper($tmpobjectkey)."_ADDON";
+ dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
+ }
+} elseif ($action == 'set') {
+ // Activate a model
+ $ret = addDocumentModel($value, $type, $label, $scandir);
+} elseif ($action == 'del') {
+ $ret = delDocumentModel($value, $type);
+ if ($ret > 0) {
+ $tmpobjectkey = GETPOST('object');
+ if (!empty($tmpobjectkey)) {
+ $constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
+ if ($conf->global->$constforval == "$value") {
+ dolibarr_del_const($db, $constforval, $conf->entity);
+ }
+ }
+ }
+} elseif ($action == 'setdoc') {
+ // Set or unset default model
+ $tmpobjectkey = GETPOST('object');
+ if (!empty($tmpobjectkey)) {
+ $constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
+ if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
+ // The constant that was read before the new set
+ // We therefore requires a variable to have a coherent view
+ $conf->global->$constforval = $value;
+ }
+
+ // We disable/enable the document template (into llx_document_model table)
+ $ret = delDocumentModel($value, $type);
+ if ($ret > 0) {
+ $ret = addDocumentModel($value, $type, $label, $scandir);
+ }
+ }
+} elseif ($action == 'unsetdoc') {
+ $tmpobjectkey = GETPOST('object');
+ if (!empty($tmpobjectkey)) {
+ $constforval = 'ASSET_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
+ dolibarr_del_const($db, $constforval, $conf->entity);
+ }
+}
+
/*
* View
*/
-llxHeader('', $langs->trans("AssetsSetup"));
+$form = new Form($db);
-$linkback = ''.$langs->trans("BackToModuleList").'';
-print load_fiche_titre($langs->trans("AssetsSetup"), $linkback, 'title_setup');
+$help_url = '';
+$page_name = "AssetSetup";
+
+llxHeader('', $langs->trans($page_name), $help_url);
+
+// Subheader
+$linkback = ''.$langs->trans("BackToModuleList").'';
+
+print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
+
+// Configuration header
+$head = assetAdminPrepareHead();
+print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "asset");
+
+// Setup page goes here
+echo ''.$langs->trans("AssetSetupPage").'';
-$head = asset_admin_prepare_head();
+$moduledir = 'asset';
+$myTmpObjects = array();
+$myTmpObjects['Asset'] = array('includerefgeneration'=>1, 'includedocgeneration'=>0);
-print dol_get_fiche_head($head, 'settings', $langs->trans("Assets"), -1, 'generic');
+foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
+ if ($myTmpObjectKey == 'MyObject') {
+ continue;
+ }
+ if ($myTmpObjectArray['includerefgeneration']) {
+ /*
+ * Orders Numbering model
+ */
+ $setupnotempty++;
+
+ print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
+
+ print '';
+ print '';
+ print '| '.$langs->trans("Name").' | ';
+ print ''.$langs->trans("Description").' | ';
+ print ''.$langs->trans("Example").' | ';
+ print ''.$langs->trans("Status").' | ';
+ print ''.$langs->trans("ShortInfo").' | ';
+ print ' '."\n";
+
+ clearstatcache();
+
+ foreach ($dirmodels as $reldir) {
+ $dir = dol_buildpath($reldir."core/modules/".$moduledir);
+
+ if (is_dir($dir)) {
+ $handle = opendir($dir);
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php') {
+ $file = substr($file, 0, dol_strlen($file) - 4);
+
+ require_once $dir.'/'.$file.'.php';
+
+ $module = new $file($db);
+
+ // 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()) {
+ dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
+
+ print '| '.$module->name." | \n";
+ print $module->info();
+ print ' | ';
+
+ // Show example of numbering model
+ print '';
+ $tmp = $module->getExample();
+ if (preg_match('/^Error/', $tmp)) {
+ $langs->load("errors");
+ print ' '.$langs->trans($tmp).' ';
+ } elseif ($tmp == 'NotConfigured') {
+ print $langs->trans($tmp);
+ } else {
+ print $tmp;
+ }
+ print ' | '."\n";
+
+ print '';
+ $constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
+ if ($conf->global->$constforvar == $file) {
+ print img_picto($langs->trans("Activated"), 'switch_on');
+ } else {
+ print '';
+ print img_picto($langs->trans("Disabled"), 'switch_off');
+ print '';
+ }
+ print ' | ';
+
+ $mytmpinstance = new $myTmpObjectKey($db);
+ $mytmpinstance->initAsSpecimen();
+
+ // Info
+ $htmltooltip = '';
+ $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().' ';
+
+ $nextval = $module->getNextValue($mytmpinstance);
+ if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
+ $htmltooltip .= ''.$langs->trans("NextValue").': ';
+ if ($nextval) {
+ if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
+ $nextval = $langs->trans($nextval);
+ }
+ $htmltooltip .= $nextval.' ';
+ } else {
+ $htmltooltip .= $langs->trans($module->error).' ';
+ }
+ }
+
+ print '';
+ print $form->textwithpicto('', $htmltooltip, 1, 0);
+ print ' | ';
+
+ print " \n";
+ }
+ }
+ }
+ closedir($handle);
+ }
+ }
+ }
+ print " \n";
+ }
+
+ if ($myTmpObjectArray['includedocgeneration']) {
+ /*
+ * Document templates generators
+ */
+ $setupnotempty++;
+ $type = strtolower($myTmpObjectKey);
+
+ print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
+
+ // Load array def with activated templates
+ $def = array();
+ $sql = "SELECT nom";
+ $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
+ $sql .= " WHERE type = '".$db->escape($type)."'";
+ $sql .= " AND entity = ".$conf->entity;
+ $resql = $db->query($sql);
+ if ($resql) {
+ $i = 0;
+ $num_rows = $db->num_rows($resql);
+ while ($i < $num_rows) {
+ $array = $db->fetch_array($resql);
+ array_push($def, $array[0]);
+ $i++;
+ }
+ } else {
+ dol_print_error($db);
+ }
+
+ print "\n";
+ print "\n";
+ print '| '.$langs->trans("Name").' | ';
+ print ''.$langs->trans("Description").' | ';
+ print ''.$langs->trans("Status")." | \n";
+ print ''.$langs->trans("Default")." | \n";
+ print ''.$langs->trans("ShortInfo").' | ';
+ print ''.$langs->trans("Preview").' | ';
+ print " \n";
+
+ clearstatcache();
+
+ foreach ($dirmodels as $reldir) {
+ foreach (array('', '/doc') as $valdir) {
+ $realpath = $reldir."core/modules/".$moduledir.$valdir;
+ $dir = dol_buildpath($realpath);
+
+ if (is_dir($dir)) {
+ $handle = opendir($dir);
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ $filelist[] = $file;
+ }
+ closedir($handle);
+ arsort($filelist);
+
+ foreach ($filelist as $file) {
+ if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
+ if (file_exists($dir.'/'.$file)) {
+ $name = substr($file, 4, dol_strlen($file) - 16);
+ $classname = substr($file, 0, dol_strlen($file) - 12);
+
+ require_once $dir.'/'.$file;
+ $module = new $classname($db);
+
+ $modulequalified = 1;
+ if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
+ $modulequalified = 0;
+ }
+ if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
+ $modulequalified = 0;
+ }
+
+ if ($modulequalified) {
+ print '| ';
+ print (empty($module->name) ? $name : $module->name);
+ print " | \n";
+ if (method_exists($module, 'info')) {
+ print $module->info($langs);
+ } else {
+ print $module->description;
+ }
+ print ' | ';
+
+ // Active
+ if (in_array($name, $def)) {
+ print ''."\n";
+ print '';
+ 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 " | ";
+ }
+
+ // Default
+ print '';
+ $constforvar = 'ASSET_'.strtoupper($myTmpObjectKey).'_ADDON';
+ if ($conf->global->$constforvar == $name) {
+ //print img_picto($langs->trans("Default"), 'on');
+ // Even if choice is the default value, we allow to disable it. Replace this with previous line if you need to disable unset
+ print 'scandir).'&label='.urlencode($module->name).'&type='.urlencode($type).'" alt="'.$langs->trans("Disable").'">'.img_picto($langs->trans("Enabled"), 'on').'';
+ } else {
+ print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'';
+ }
+ print ' | ';
+
+ // Info
+ $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+ $htmltooltip .= ' '.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
+ if ($module->type == 'pdf') {
+ $htmltooltip .= ' '.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+ }
+ $htmltooltip .= ' '.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+ $htmltooltip .= '
'.$langs->trans("FeaturesSupported").':';
+ $htmltooltip .= ' '.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
+ $htmltooltip .= ' '.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+
+ print '';
+ print $form->textwithpicto('', $htmltooltip, 1, 0);
+ print ' | ';
+
+ // Preview
+ print '';
+ if ($module->type == 'pdf') {
+ print ''.img_object($langs->trans("Preview"), 'pdf').'';
+ } else {
+ print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+ }
+ print ' | ';
+
+ print " \n";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ print ' ';
+ }
+}
if ($action == 'edit') {
print '';
print ' ';
} else {
- print '';
- print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ';
+ if (!empty($arrayofparameters)) {
+ print '';
+ print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ';
- foreach ($arrayofparameters as $key => $val) {
- print '| ';
- print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
- print ' | '.$conf->global->$key.' | ';
+ foreach ($arrayofparameters as $constname => $val) {
+ if ($val['enabled']==1) {
+ $setupnotempty++;
+ print '| ';
+ $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : '');
+ print $form->textwithpicto($langs->trans($constname), $tooltiphelp);
+ print ' | ';
+
+ if ($val['type'] == 'textarea') {
+ print dol_nl2br($conf->global->{$constname});
+ } elseif ($val['type']== 'html') {
+ print $conf->global->{$constname};
+ } elseif ($val['type'] == 'yesno') {
+ print ajax_constantonoff($constname);
+ } elseif (preg_match('/emailtemplate:/', $val['type'])) {
+ include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+
+ $tmp = explode(':', $val['type']);
+
+ $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
+ if ($template<0) {
+ setEventMessages(null, $formmail->errors, 'errors');
+ }
+ print $langs->trans($template->label);
+ } elseif (preg_match('/category:/', $val['type'])) {
+ $c = new Categorie($db);
+ $result = $c->fetch($conf->global->{$constname});
+ if ($result < 0) {
+ setEventMessages(null, $c->errors, 'errors');
+ } elseif ($result > 0 ) {
+ $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
+ $toprint = array();
+ foreach ($ways as $way) {
+ $toprint[] = 'color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '';
+ }
+ print '' . implode(' ', $toprint) . ' ';
+ }
+ } elseif (preg_match('/thirdparty_type/', $val['type'])) {
+ if ($conf->global->{$constname}==2) {
+ print $langs->trans("Prospect");
+ } elseif ($conf->global->{$constname}==3) {
+ print $langs->trans("ProspectCustomer");
+ } elseif ($conf->global->{$constname}==1) {
+ print $langs->trans("Customer");
+ } elseif ($conf->global->{$constname}==0) {
+ print $langs->trans("NorProspectNorCustomer");
+ }
+ } elseif ($val['type'] == 'product') {
+ $product = new Product($db);
+ $resprod = $product->fetch($conf->global->{$constname});
+ if ($resprod > 0) {
+ print $product->ref;
+ } elseif ($resprod < 0) {
+ setEventMessages(null, $object->errors, "errors");
+ }
+ } elseif ($val['type'] == 'accountancy_code') {
+ if (!empty($conf->accounting->enabled)) {
+ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
+ $accountingaccount = new AccountingAccount($db);
+ $accountingaccount->fetch('', $conf->global->{$constname}, 1);
+
+ print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
+ } else {
+ print $conf->global->{$constname};
+ }
+ } else {
+ print $conf->global->{$constname};
+ }
+ print ' | ';
+ }
+ }
+
+ print ' ';
+
+ print '';
+ } else {
+ print ' '.$langs->trans("NothingToSetup");
}
-
- print ' ';
-
- print '';
}
+if (empty($setupnotempty)) {
+ print ' '.$langs->trans("NothingToSetup");
+}
+
+// Page end
print dol_get_fiche_end();
-// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php
new file mode 100644
index 00000000000..49a0c215701
--- /dev/null
+++ b/htdocs/asset/agenda.php
@@ -0,0 +1,215 @@
+
+ * Copyright (C) ---Put here your own copyright and developer email---
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/asset/agenda.php
+ * \ingroup asset
+ * \brief Tab of events on Asset
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("assets", "other"));
+
+// Get parameters
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'aZ09');
+$backtopage = GETPOST('backtopage', 'alpha');
+
+if (GETPOST('actioncode', 'array')) {
+ $actioncode = GETPOST('actioncode', 'array', 3);
+ if (!count($actioncode)) {
+ $actioncode = '0';
+ }
+} else {
+ $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
+}
+$search_agenda_label = GETPOST('search_agenda_label');
+
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+$sortfield = GETPOST("sortfield", 'alpha');
+$sortorder = GETPOST("sortorder", 'alpha');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
+$offset = $limit * $page;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (!$sortfield) {
+ $sortfield = 'a.datep,a.id';
+}
+if (!$sortorder) {
+ $sortorder = 'DESC,DESC';
+}
+
+// Initialize technical objects
+$object = new Asset($db);
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->asset->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('assetagenda', 'globalcard')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+if ($id > 0 || !empty($ref)) {
+ $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id;
+}
+
+$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php
+
+// Security check (enable the most restrictive one)
+if ($user->socid > 0) accessforbidden();
+$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
+restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
+if (empty($conf->asset->enabled)) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+$parameters = array('id'=>$id);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+
+if (empty($reshook)) {
+ // Cancel
+ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
+ header("Location: ".$backtopage);
+ exit;
+ }
+
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
+ $actioncode = '';
+ $search_agenda_label = '';
+ }
+}
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+if ($object->id > 0) {
+ $title = $langs->trans("Agenda");
+ //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
+ $help_url = 'EN:Module_Agenda_En';
+ llxHeader('', $title, $help_url);
+
+ if (!empty($conf->notification->enabled)) {
+ $langs->load("mails");
+ }
+ $head = assetPrepareHead($object);
+
+
+ print dol_get_fiche_head($head, 'agenda', $langs->trans("Asset"), -1, $object->picto);
+
+ // Object card
+ // ------------------------------------------------------------
+ $linkback = '' . $langs->trans("BackToList") . '';
+
+ $morehtmlref = '';
+ $morehtmlref .= ' ';
+
+
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
+
+ print '';
+ print ' ';
+
+ $object->info($object->id);
+ dol_print_object_info($object, 1);
+
+ print ' ';
+
+ print dol_get_fiche_end();
+
+
+ // Actions buttons
+
+ $objthirdparty = $object;
+ $objcon = new stdClass();
+
+ $out = '&origin=' . urlencode($object->element . '@' . $object->module) . '&originid=' . urlencode($object->id);
+ $urlbacktopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id;
+ $out .= '&backtopage=' . urlencode($urlbacktopage);
+ $permok = $user->rights->agenda->myactions->create;
+ if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
+ //$out.='trans("AddAnAction"),'filenew');
+ //$out.="";
+ }
+
+
+ print '';
+
+ if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
+ $param = '&id=' . $object->id . '&socid=' . $socid;
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage=' . urlencode($contextpage);
+ }
+ if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit=' . urlencode($limit);
+ }
+
+
+ print load_fiche_titre($langs->trans("ActionsOnAsset"), '', '');
+
+ // List of all actions
+ $filters = array();
+ $filters['search_agenda_label'] = $search_agenda_label;
+
+ // TODO Replace this with same code than into list.php
+ show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
+ }
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php
index 35c0ffcff88..c516866b7d0 100644
--- a/htdocs/asset/card.php
+++ b/htdocs/asset/card.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2018 Alexandre Spangaro
+/* Copyright (C) 2017 Laurent Destailleur
+ * Copyright (C) 2018 Alexandre Spangaro
*
* 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
@@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("asset"));
+$langs->loadLangs(array("assets", "other"));
// Get parameters
$id = GETPOST('id', 'int');
@@ -68,12 +68,6 @@ if (empty($action) && empty($id) && empty($ref)) {
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
-// Security check
-if (!empty($user->socid)) {
- $socid = $user->socid;
-}
-$result = restrictedArea($user, 'asset', $id);
-
$permissiontoread = $user->rights->asset->read;
$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->asset->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
@@ -81,7 +75,13 @@ $permissionnote = $user->rights->asset->write; // Used by the include of actions
$permissiondellink = $user->rights->asset->write; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1];
-$error = 0;
+// Security check (enable the most restrictive one)
+if ($user->socid > 0) accessforbidden();
+if ($user->socid > 0) $socid = $user->socid;
+$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
+restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
+if (empty($conf->asset->enabled)) accessforbidden();
+if (!$permissiontoread) accessforbidden();
/*
@@ -95,6 +95,8 @@ if ($reshook < 0) {
}
if (empty($reshook)) {
+ $error = 0;
+
$backurlforlist = DOL_URL_ROOT.'/asset/list.php';
if (empty($backtopage) || ($cancel && empty($id))) {
@@ -107,6 +109,27 @@ if (empty($reshook)) {
}
}
+ $object->oldcopy = dol_clone($object);
+ $triggermodname = 'ASSET_MODIFY'; // Name of trigger action code to execute when we modify record
+
+ // Action dispose object
+ if ($action == 'confirm_disposal' && $confirm == 'yes' && $permissiontoadd) {
+ $object->disposal_date = dol_mktime(12, 0, 0, GETPOST('disposal_datemonth', 'int'), GETPOST('disposal_dateday', 'int'), GETPOST('disposal_dateyear', 'int')); // for date without hour, we use gmt
+ $object->disposal_amount_ht = GETPOST('disposal_amount', 'int');
+ $object->fk_disposal_type = GETPOST('fk_disposal_type', 'int');
+ $disposal_invoice_id = GETPOST('disposal_invoice_id', 'int');
+ $object->disposal_depreciated = ((GETPOST('disposal_depreciated') == '1' || GETPOST('disposal_depreciated') == 'on') ? 1 : 0);
+ $object->disposal_subject_to_vat = ((GETPOST('disposal_subject_to_vat') == '1' || GETPOST('disposal_subject_to_vat') == 'on') ? 1 : 0);
+
+ $result = $object->dispose($user, $disposal_invoice_id);
+ if ($result < 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ $action = '';
+ } elseif ($action == "add") {
+ $object->supplier_invoice_id = GETPOST('supplier_invoice_id', 'int');
+ }
+
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
@@ -122,13 +145,6 @@ if (empty($reshook)) {
// Action to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
- if ($action == 'set_thirdparty' && $permissiontoadd) {
- $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY');
- }
- if ($action == 'classin' && $permissiontoadd) {
- $object->setProject(GETPOST('projectid', 'int'));
- }
-
// Actions to send emails
$triggersendname = 'ASSET_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_ASSET_TO';
@@ -136,6 +152,7 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
+
/*
* View
*
@@ -150,7 +167,7 @@ llxHeader('', $title, $help_url);
// Part to create
if ($action == 'create') {
- print load_fiche_titre($langs->trans("NewAsset"), '', $object->picto);
+ print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Asset")), '', 'object_'.$object->picto);
print ' | |