| Conditions | 157 |
| Total Lines | 633 |
| Code Lines | 401 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 112 | function setValues($db) |
||
| 113 | {
|
||
| 114 | global $conf; |
||
| 115 | |||
| 116 | dol_syslog(get_class($this) . "::setValues"); |
||
| 117 | |||
| 118 | //Define all global constants into $this->global->key=value |
||
| 119 | $sql = "SELECT " . $db->decrypt('name') . " as name,";
|
||
| 120 | $sql .= " " . $db->decrypt('value') . " as value, entity";
|
||
| 121 | $sql .= " FROM " . MAIN_DB_PREFIX . "const"; |
||
| 122 | $sql .= " WHERE entity IN (0," . $this->entity . ")"; |
||
| 123 | $sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite. |
||
| 124 | |||
| 125 | $resql = $db->query($sql); |
||
| 126 | if ($resql) {
|
||
| 127 | $i = 0; |
||
| 128 | $numr = $db->num_rows($resql); |
||
| 129 | while ($i < $numr) {
|
||
| 130 | $objp = $db->fetch_object($resql); |
||
| 131 | $key = $objp->name; |
||
| 132 | $value = $objp->value; |
||
| 133 | if ($key) {
|
||
| 134 | //if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
|
||
| 135 | $this->global->$key = $value; |
||
| 136 | |||
| 137 | if ($value && preg_match('/^MAIN_MODULE_/', $key)) {
|
||
| 138 | // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs']. |
||
| 139 | if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
|
||
| 140 | $partname = 'tabs'; |
||
| 141 | $params = explode(':', $value, 2);
|
||
| 142 | if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
|
||
| 143 | $this->modules_parts[$partname] = array(); |
||
| 144 | } |
||
| 145 | $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array |
||
| 146 | } |
||
| 147 | // If this is constant for all generic part activated by a module. It initializes |
||
| 148 | // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'], |
||
| 149 | // modules_parts['models'], modules_parts['theme'] |
||
| 150 | // modules_parts['sms'], |
||
| 151 | // modules_parts['css'], ... |
||
| 152 | elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
|
||
| 153 | $modulename = strtolower($reg[1]); |
||
| 154 | $partname = strtolower($reg[2]); |
||
| 155 | if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
|
||
| 156 | $this->modules_parts[$partname] = array(); |
||
| 157 | } |
||
| 158 | $arrValue = json_decode($value, true); |
||
| 159 | if (is_array($arrValue) && !empty($arrValue)) |
||
| 160 | $value = $arrValue; |
||
| 161 | else if (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl')))
|
||
| 162 | $value = '/' . $modulename . '/core/' . $partname . '/'; |
||
| 163 | else if (in_array($partname, array('models', 'theme')))
|
||
| 164 | $value = '/' . $modulename . '/'; |
||
| 165 | else if (in_array($partname, array('sms')))
|
||
| 166 | $value = '/' . $modulename . '/'; |
||
| 167 | else if ($value == 1) |
||
| 168 | $value = '/' . $modulename . '/core/modules/' . $partname . '/'; // ex: partname = societe |
||
| 169 | $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array |
||
| 170 | } |
||
| 171 | // If this is a module constant (must be at end) |
||
| 172 | elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
|
||
| 173 | $modulename = strtolower($reg[1]); |
||
| 174 | if ($modulename == 'propale') |
||
| 175 | $modulename = 'propal'; |
||
| 176 | if ($modulename == 'supplierproposal') |
||
| 177 | $modulename = 'supplier_proposal'; |
||
| 178 | if (!isset($this->$modulename) || !is_object($this->$modulename)) |
||
| 179 | $this->$modulename = new \stdClass(); |
||
| 180 | $this->$modulename->enabled = true; |
||
| 181 | $this->modules[] = $modulename; // Add this module in list of enabled modules |
||
| 182 | } |
||
| 183 | } |
||
| 184 | } |
||
| 185 | $i++; |
||
| 186 | } |
||
| 187 | |||
| 188 | $db->free($resql); |
||
| 189 | } |
||
| 190 | |||
| 191 | // Include other local consts.php files and fetch their values to the corresponding database constants. |
||
| 192 | if (!empty($this->global->LOCAL_CONSTS_FILES)) {
|
||
| 193 | $filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
|
||
| 194 | foreach ($filesList as $file) {
|
||
| 195 | $file = dol_sanitizeFileName($file); |
||
| 196 | include_once DOL_DOCUMENT_ROOT . "/" . $file . "/" . $file . "_consts.php"; |
||
| 197 | foreach ($file2bddconsts as $key => $value) {
|
||
| 198 | $this->global->$key = $value; |
||
| 199 | } |
||
| 200 | } |
||
| 201 | } |
||
| 202 | |||
| 203 | //var_dump($this->modules); |
||
| 204 | //var_dump($this->modules_parts['theme']); |
||
| 205 | // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. |
||
| 206 | // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. |
||
| 207 | //$this->global->MAIN_SERVER_TZ='Europe/Paris'; |
||
| 208 | if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') {
|
||
| 209 | try {
|
||
| 210 | date_default_timezone_set($this->global->MAIN_SERVER_TZ); |
||
| 211 | } catch (Exception $e) {
|
||
| 212 | dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=" . $this->global->MAIN_SERVER_TZ, LOG_ERR);
|
||
| 213 | } |
||
| 214 | } |
||
| 215 | |||
| 216 | // Object $mc |
||
| 217 | if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
|
||
| 218 | global $mc; |
||
| 219 | $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||
| 220 | if ($ret) {
|
||
| 221 | $mc = new ActionsMulticompany($db); |
||
| 222 | $this->mc = $mc; |
||
| 223 | } |
||
| 224 | } |
||
| 225 | |||
| 226 | // Clean some variables |
||
| 227 | if (empty($this->global->MAIN_MENU_STANDARD)) |
||
| 228 | $this->global->MAIN_MENU_STANDARD = "eldy_menu.php"; |
||
| 229 | if (empty($this->global->MAIN_MENUFRONT_STANDARD)) |
||
| 230 | $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php"; |
||
| 231 | if (empty($this->global->MAIN_MENU_SMARTPHONE)) |
||
| 232 | $this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones |
||
| 233 | if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) |
||
| 234 | $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones |
||
| 235 | |||
| 236 | |||
| 237 | |||
| 238 | |||
| 239 | // Clean var use vat for company |
||
| 240 | if (!isset($this->global->FACTURE_TVAOPTION)) |
||
| 241 | $this->global->FACTURE_TVAOPTION = 1; |
||
| 242 | else if (!empty($this->global->FACTURE_TVAOPTION) && !is_numeric($this->global->FACTURE_TVAOPTION)) {
|
||
| 243 | // Old value of option, we clean to use new value (0 or 1) |
||
| 244 | if ($this->global->FACTURE_TVAOPTION != "franchise") |
||
| 245 | $this->global->FACTURE_TVAOPTION = 1; |
||
| 246 | else |
||
| 247 | $this->global->FACTURE_TVAOPTION = 0; |
||
| 248 | } |
||
| 249 | |||
| 250 | // Variable globales LDAP |
||
| 251 | if (empty($this->global->LDAP_FIELD_FULLNAME)) |
||
| 252 | $this->global->LDAP_FIELD_FULLNAME = ''; |
||
| 253 | if (!isset($this->global->LDAP_KEY_USERS)) |
||
| 254 | $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME; |
||
| 255 | if (!isset($this->global->LDAP_KEY_GROUPS)) |
||
| 256 | $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME; |
||
| 257 | if (!isset($this->global->LDAP_KEY_CONTACTS)) |
||
| 258 | $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME; |
||
| 259 | if (!isset($this->global->LDAP_KEY_MEMBERS)) |
||
| 260 | $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME; |
||
| 261 | if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) |
||
| 262 | $this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME; |
||
| 263 | |||
| 264 | // Load translation object with current language |
||
| 265 | if (empty($this->global->MAIN_LANG_DEFAULT)) |
||
| 266 | $this->global->MAIN_LANG_DEFAULT = "en_US"; |
||
| 267 | |||
| 268 | $rootfordata = DOL_DATA_ROOT; |
||
| 269 | $rootforuser = DOL_DATA_ROOT; |
||
| 270 | // If multicompany module is enabled, we redefine the root of data |
||
| 271 | if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1) {
|
||
| 272 | $rootfordata .= '/' . $this->entity; |
||
| 273 | } |
||
| 274 | |||
| 275 | // Define default dir_output and dir_temp for directories of modules |
||
| 276 | foreach ($this->modules as $module) {
|
||
| 277 | //var_dump($module); |
||
| 278 | // For multicompany sharings |
||
| 279 | $this->$module->multidir_output = array($this->entity => $rootfordata . "/" . $module); |
||
| 280 | $this->$module->multidir_temp = array($this->entity => $rootfordata . "/" . $module . "/temp"); |
||
| 281 | // For backward compatibility |
||
| 282 | $this->$module->dir_output = $rootfordata . "/" . $module; |
||
| 283 | $this->$module->dir_temp = $rootfordata . "/" . $module . "/temp"; |
||
| 284 | } |
||
| 285 | |||
| 286 | // External modules storage |
||
| 287 | if (!empty($this->modules_parts['dir'])) {
|
||
| 288 | foreach ($this->modules_parts['dir'] as $module => $dirs) {
|
||
| 289 | if (!empty($this->$module->enabled)) {
|
||
| 290 | foreach ($dirs as $type => $name) {
|
||
| 291 | $subdir = ($type == 'temp' ? '/temp' : ''); |
||
| 292 | // For multicompany sharings |
||
| 293 | $varname = 'multidir_' . $type; |
||
| 294 | $this->$module->$varname = array($this->entity => $rootfordata . "/" . $name . $subdir); |
||
| 295 | // For backward compatibility |
||
| 296 | $varname = 'dir_' . $type; |
||
| 297 | $this->$module->$varname = $rootfordata . "/" . $name . $subdir; |
||
| 298 | } |
||
| 299 | } |
||
| 300 | } |
||
| 301 | } |
||
| 302 | |||
| 303 | // For mycompany storage |
||
| 304 | $this->mycompany->dir_output = $rootfordata . "/mycompany"; |
||
| 305 | $this->mycompany->dir_temp = $rootfordata . "/mycompany/temp"; |
||
| 306 | |||
| 307 | // For admin storage |
||
| 308 | $this->admin->dir_output = $rootfordata . '/admin'; |
||
| 309 | $this->admin->dir_temp = $rootfordata . '/admin/temp'; |
||
| 310 | |||
| 311 | // For user storage |
||
| 312 | $this->user->multidir_output = array($this->entity => $rootfordata . "/users"); |
||
| 313 | $this->user->multidir_temp = array($this->entity => $rootfordata . "/users/temp"); |
||
| 314 | // For backward compatibility |
||
| 315 | $this->user->dir_output = $rootforuser . "/users"; |
||
| 316 | $this->user->dir_temp = $rootforuser . "/users/temp"; |
||
| 317 | |||
| 318 | // For usergroup storage |
||
| 319 | $this->usergroup->dir_output = $rootforuser . "/usergroups"; |
||
| 320 | $this->usergroup->dir_temp = $rootforuser . "/usergroups/temp"; |
||
| 321 | |||
| 322 | // For proposal storage |
||
| 323 | $this->propal->multidir_output = array($this->entity => $rootfordata . "/propale"); |
||
| 324 | $this->propal->multidir_temp = array($this->entity => $rootfordata . "/propale/temp"); |
||
| 325 | // For backward compatibility |
||
| 326 | $this->propal->dir_output = $rootfordata . "/propale"; |
||
| 327 | $this->propal->dir_temp = $rootfordata . "/propale/temp"; |
||
| 328 | |||
| 329 | // For medias storage |
||
| 330 | $this->medias->multidir_output = array($this->entity => $rootfordata . "/medias"); |
||
| 331 | $this->medias->multidir_temp = array($this->entity => $rootfordata . "/medias/temp"); |
||
| 332 | |||
| 333 | // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. |
||
| 334 | // Sous module bons d'expedition |
||
| 335 | $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0); |
||
| 336 | // Sous module bons de livraison |
||
| 337 | $this->livraison_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_LIVRAISON) ? $this->global->MAIN_SUBMODULE_LIVRAISON : 0); |
||
| 338 | |||
| 339 | // Module fournisseur |
||
| 340 | if (!empty($this->fournisseur)) {
|
||
| 341 | $this->fournisseur->commande = new \stdClass(); |
||
| 342 | $this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata . "/fournisseur/commande"); |
||
| 343 | $this->fournisseur->commande->multidir_temp = array($this->entity => $rootfordata . "/fournisseur/commande/temp"); |
||
| 344 | $this->fournisseur->commande->dir_output = $rootfordata . "/fournisseur/commande"; // For backward compatibility |
||
| 345 | $this->fournisseur->commande->dir_temp = $rootfordata . "/fournisseur/commande/temp"; // For backward compatibility |
||
| 346 | $this->fournisseur->facture = new \stdClass(); |
||
| 347 | $this->fournisseur->facture->multidir_output = array($this->entity => $rootfordata . "/fournisseur/facture"); |
||
| 348 | $this->fournisseur->facture->multidir_temp = array($this->entity => $rootfordata . "/fournisseur/facture/temp"); |
||
| 349 | $this->fournisseur->facture->dir_output = $rootfordata . "/fournisseur/facture"; // For backward compatibility |
||
| 350 | $this->fournisseur->facture->dir_temp = $rootfordata . "/fournisseur/facture/temp"; // For backward compatibility |
||
| 351 | $this->supplierproposal = new \stdClass(); |
||
| 352 | $this->supplierproposal->multidir_output = array($this->entity => $rootfordata . "/supplier_proposal"); |
||
| 353 | $this->supplierproposal->multidir_temp = array($this->entity => $rootfordata . "/supplier_proposal/temp"); |
||
| 354 | $this->supplierproposal->dir_output = $rootfordata . "/supplier_proposal"; // For backward compatibility |
||
| 355 | $this->supplierproposal->dir_temp = $rootfordata . "/supplier_proposal/temp"; // For backward compatibility |
||
| 356 | $this->fournisseur->payment = new \stdClass(); |
||
| 357 | $this->fournisseur->payment->multidir_output = array($this->entity => $rootfordata . "/fournisseur/payment"); |
||
| 358 | $this->fournisseur->payment->multidir_temp = array($this->entity => $rootfordata . "/fournisseur/payment/temp"); |
||
| 359 | $this->fournisseur->payment->dir_output = $rootfordata . "/fournisseur/payment"; // For backward compatibility |
||
| 360 | $this->fournisseur->payment->dir_temp = $rootfordata . "/fournisseur/payment/temp"; // For backward compatibility |
||
| 361 | // To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice |
||
| 362 | if (!empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) { // By default, if module supplier is on, we set new properties
|
||
| 363 | $this->supplier_order = new \stdClass(); |
||
| 364 | $this->supplier_order->enabled = 1; |
||
| 365 | $this->supplier_order->multidir_output = array($this->entity => $rootfordata . "/fournisseur/commande"); |
||
| 366 | $this->supplier_order->multidir_temp = array($this->entity => $rootfordata . "/fournisseur/commande/temp"); |
||
| 367 | $this->supplier_order->dir_output = $rootfordata . "/fournisseur/commande"; // For backward compatibility |
||
| 368 | $this->supplier_order->dir_temp = $rootfordata . "/fournisseur/commande/temp"; // For backward compatibility |
||
| 369 | $this->supplier_invoice = new \stdClass(); |
||
| 370 | $this->supplier_invoice->enabled = 1; |
||
| 371 | $this->supplier_invoice->multidir_output = array($this->entity => $rootfordata . "/fournisseur/facture"); |
||
| 372 | $this->supplier_invoice->multidir_temp = array($this->entity => $rootfordata . "/fournisseur/facture/temp"); |
||
| 373 | $this->supplier_invoice->dir_output = $rootfordata . "/fournisseur/facture"; // For backward compatibility |
||
| 374 | $this->supplier_invoice->dir_temp = $rootfordata . "/fournisseur/facture/temp"; // For backward compatibility |
||
| 375 | $this->supplierproposal = new \stdClass(); |
||
| 376 | $this->supplierproposal->multidir_output = array($this->entity => $rootfordata . "/supplier_proposal"); |
||
| 377 | $this->supplierproposal->multidir_temp = array($this->entity => $rootfordata . "/supplier_proposal/temp"); |
||
| 378 | $this->supplierproposal->dir_output = $rootfordata . "/supplier_proposal"; // For backward compatibility |
||
| 379 | $this->supplierproposal->dir_temp = $rootfordata . "/supplier_proposal/temp"; // For backward compatibility |
||
| 380 | } |
||
| 381 | } |
||
| 382 | |||
| 383 | // Module product/service |
||
| 384 | $this->product->multidir_output = array($this->entity => $rootfordata . "/produit"); |
||
| 385 | $this->product->multidir_temp = array($this->entity => $rootfordata . "/produit/temp"); |
||
| 386 | $this->service->multidir_output = array($this->entity => $rootfordata . "/produit"); |
||
| 387 | $this->service->multidir_temp = array($this->entity => $rootfordata . "/produit/temp"); |
||
| 388 | // For backward compatibility |
||
| 389 | $this->product->dir_output = $rootfordata . "/produit"; |
||
| 390 | $this->product->dir_temp = $rootfordata . "/produit/temp"; |
||
| 391 | $this->service->dir_output = $rootfordata . "/produit"; |
||
| 392 | $this->service->dir_temp = $rootfordata . "/produit/temp"; |
||
| 393 | |||
| 394 | // Module productbatch |
||
| 395 | $this->productbatch->multidir_output = array($this->entity => $rootfordata . "/produitlot"); |
||
| 396 | $this->productbatch->multidir_temp = array($this->entity => $rootfordata . "/produitlot/temp"); |
||
| 397 | |||
| 398 | // Module contrat |
||
| 399 | $this->contrat->multidir_output = array($this->entity => $rootfordata . "/contract"); |
||
| 400 | $this->contrat->multidir_temp = array($this->entity => $rootfordata . "/contract/temp"); |
||
| 401 | // For backward compatibility |
||
| 402 | $this->contrat->dir_output = $rootfordata . "/contract"; |
||
| 403 | $this->contrat->dir_temp = $rootfordata . "/contract/temp"; |
||
| 404 | |||
| 405 | // Module bank |
||
| 406 | $this->bank->dir_output = $rootfordata . "/bank"; |
||
| 407 | $this->bank->dir_temp = $rootfordata . "/bank/temp"; |
||
| 408 | |||
| 409 | |||
| 410 | // Set some default values |
||
| 411 | //$this->global->MAIN_LIST_FILTER_ON_DAY=1; // On filter that show date, we must show input field for day before or after month |
||
| 412 | $this->global->MAIN_ACTIVATE_HTML5 = 1; |
||
| 413 | $this->global->MAIN_MAIL_USE_MULTI_PART = 1; |
||
| 414 | |||
| 415 | // societe |
||
| 416 | if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) |
||
| 417 | $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; |
||
| 418 | if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) |
||
| 419 | $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum"; |
||
| 420 | |||
| 421 | if (empty($this->global->CHEQUERECEIPTS_ADDON)) |
||
| 422 | $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint'; |
||
| 423 | if (empty($conf->global->TICKETSUP_ADDON)) |
||
| 424 | $this->global->TICKETSUP_ADDON = 'mod_ticket_simple'; |
||
| 425 | |||
| 426 | // Security |
||
| 427 | if (empty($this->global->USER_PASSWORD_GENERATED)) |
||
| 428 | $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator |
||
| 429 | if (empty($this->global->MAIN_UMASK)) |
||
| 430 | $this->global->MAIN_UMASK = '0664'; // Default mask |
||
| 431 | |||
| 432 | |||
| 433 | |||
| 434 | |||
| 435 | |||
| 436 | // conf->use_javascript_ajax |
||
| 437 | $this->use_javascript_ajax = 1; |
||
| 438 | if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) |
||
| 439 | $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT; |
||
| 440 | // If no javascript_ajax, Ajax features are disabled. |
||
| 441 | if (empty($this->use_javascript_ajax)) {
|
||
| 442 | unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT); |
||
| 443 | unset($this->global->COMPANY_USE_SEARCH_TO_SELECT); |
||
| 444 | unset($this->global->CONTACT_USE_SEARCH_TO_SELECT); |
||
| 445 | unset($this->global->PROJECT_USE_SEARCH_TO_SELECT); |
||
| 446 | } |
||
| 447 | |||
| 448 | if (!empty($this->productbatch->enabled)) {
|
||
| 449 | $this->global->STOCK_CALCULATE_ON_BILL = 0; |
||
| 450 | $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0; |
||
| 451 | $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1; |
||
| 452 | $this->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE = 0; |
||
| 453 | $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0; |
||
| 454 | $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0; |
||
| 455 | if (empty($this->reception->enabled)) |
||
| 456 | $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1; |
||
| 457 | else {
|
||
| 458 | $this->global->STOCK_CALCULATE_ON_RECEPTION = 1; |
||
| 459 | $this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0; |
||
| 460 | } |
||
| 461 | } |
||
| 462 | |||
| 463 | // conf->currency |
||
| 464 | if (empty($this->global->MAIN_MONNAIE)) |
||
| 465 | $this->global->MAIN_MONNAIE = 'EUR'; |
||
| 466 | $this->currency = $this->global->MAIN_MONNAIE; |
||
| 467 | |||
| 468 | if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) |
||
| 469 | $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure |
||
| 470 | |||
| 471 | |||
| 472 | |||
| 473 | |||
| 474 | |||
| 475 | // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) |
||
| 476 | if (empty($this->global->ACCOUNTING_MODE)) |
||
| 477 | $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' |
||
| 478 | |||
| 479 | |||
| 480 | |||
| 481 | |||
| 482 | |||
| 483 | // By default, suppliers objects can be linked to all projects |
||
| 484 | $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; |
||
| 485 | |||
| 486 | // MAIN_HTML_TITLE |
||
| 487 | if (!isset($this->global->MAIN_HTML_TITLE)) |
||
| 488 | $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly'; |
||
| 489 | |||
| 490 | // conf->liste_limit = constante de taille maximale des listes |
||
| 491 | if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) |
||
| 492 | $this->global->MAIN_SIZE_LISTE_LIMIT = 25; |
||
| 493 | $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT; |
||
| 494 | |||
| 495 | // conf->product->limit_size = constante de taille maximale des select de produit |
||
| 496 | if (!isset($this->global->PRODUIT_LIMIT_SIZE)) |
||
| 497 | $this->global->PRODUIT_LIMIT_SIZE = 1000; |
||
| 498 | $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE; |
||
| 499 | |||
| 500 | // conf->theme et $this->css |
||
| 501 | if (empty($this->global->MAIN_THEME)) |
||
| 502 | $this->global->MAIN_THEME = "eldy"; |
||
| 503 | if (!empty($this->global->MAIN_FORCETHEME)) |
||
| 504 | $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; |
||
| 505 | $this->theme = $this->global->MAIN_THEME; |
||
| 506 | //$this->css = "/theme/".$this->theme."/style.css.php"; |
||
| 507 | $this->css = '?controller=theme/' . $this->theme . '&method=style.css'; |
||
| 508 | |||
| 509 | // conf->email_from = email pour envoi par dolibarr des mails automatiques |
||
| 510 | $this->email_from = "[email protected]"; |
||
| 511 | if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) |
||
| 512 | $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM; |
||
| 513 | |||
| 514 | // conf->notification->email_from = email pour envoi par Dolibarr des notifications |
||
| 515 | $this->notification->email_from = $this->email_from; |
||
| 516 | if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) |
||
| 517 | $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM; |
||
| 518 | |||
| 519 | // conf->mailing->email_from = email pour envoi par Dolibarr des mailings |
||
| 520 | $this->mailing->email_from = $this->email_from; |
||
| 521 | if (!empty($this->global->MAILING_EMAIL_FROM)) |
||
| 522 | $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; |
||
| 523 | if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) |
||
| 524 | $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1; |
||
| 525 | |||
| 526 | // Format for date (used by default when not found or not searched in lang) |
||
| 527 | $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) |
||
| 528 | $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags |
||
| 529 | $this->format_hour_short = "%H:%M"; |
||
| 530 | $this->format_hour_short_duration = "%H:%M"; |
||
| 531 | $this->format_date_text_short = "%d %b %Y"; |
||
| 532 | $this->format_date_text = "%d %B %Y"; |
||
| 533 | $this->format_date_hour_short = "%d/%m/%Y %H:%M"; |
||
| 534 | $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; |
||
| 535 | $this->format_date_hour_text_short = "%d %b %Y %H:%M"; |
||
| 536 | $this->format_date_hour_text = "%d %B %Y %H:%M"; |
||
| 537 | |||
| 538 | // Duration of workday |
||
| 539 | if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) |
||
| 540 | $this->global->MAIN_DURATION_OF_WORKDAY = 86400; |
||
| 541 | |||
| 542 | // Limites decimales si non definie (peuvent etre egale a 0) |
||
| 543 | if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) |
||
| 544 | $this->global->MAIN_MAX_DECIMALS_UNIT = 5; |
||
| 545 | if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) |
||
| 546 | $this->global->MAIN_MAX_DECIMALS_TOT = 2; |
||
| 547 | if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) |
||
| 548 | $this->global->MAIN_MAX_DECIMALS_SHOWN = 8; |
||
| 549 | |||
| 550 | // Default pdf option |
||
| 551 | if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) |
||
| 552 | $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines |
||
| 553 | if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) |
||
| 554 | $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text |
||
| 555 | |||
| 556 | |||
| 557 | |||
| 558 | |||
| 559 | |||
| 560 | // Set default value to MAIN_SHOW_LOGO |
||
| 561 | if (!isset($this->global->MAIN_SHOW_LOGO)) |
||
| 562 | $this->global->MAIN_SHOW_LOGO = 1; |
||
| 563 | |||
| 564 | // Default max file size for upload |
||
| 565 | $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); |
||
| 566 | |||
| 567 | // By default, we propagate contacts |
||
| 568 | if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) |
||
| 569 | $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) |
||
| 570 | |||
| 571 | |||
| 572 | |||
| 573 | |||
| 574 | |||
| 575 | // By default, we do not use the zip town table but the table of third parties |
||
| 576 | if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) |
||
| 577 | $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0; |
||
| 578 | |||
| 579 | // By default, we open card if one found |
||
| 580 | if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) |
||
| 581 | $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1; |
||
| 582 | |||
| 583 | // By default, we show state code in combo list |
||
| 584 | if (!isset($this->global->MAIN_SHOW_STATE_CODE)) |
||
| 585 | $this->global->MAIN_SHOW_STATE_CODE = 1; |
||
| 586 | |||
| 587 | // Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal" |
||
| 588 | if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) |
||
| 589 | $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later. |
||
| 590 | if (!empty($this->modules_parts['moduleforexternal'])) { // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
|
||
| 591 | foreach ($this->modules_parts['moduleforexternal'] as $key => $value) |
||
| 592 | $this->global->MAIN_MODULES_FOR_EXTERNAL .= "," . $key; |
||
| 593 | } |
||
| 594 | |||
| 595 | // Enable select2 |
||
| 596 | if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') |
||
| 597 | $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2'; |
||
| 598 | |||
| 599 | // Timeouts |
||
| 600 | if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) |
||
| 601 | $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; |
||
| 602 | if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) |
||
| 603 | $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; |
||
| 604 | |||
| 605 | // Set default variable to calculate VAT as if option tax_mode was 0 (standard) |
||
| 606 | if (empty($this->global->TAX_MODE_SELL_PRODUCT)) |
||
| 607 | $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; |
||
| 608 | if (empty($this->global->TAX_MODE_BUY_PRODUCT)) |
||
| 609 | $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; |
||
| 610 | if (empty($this->global->TAX_MODE_SELL_SERVICE)) |
||
| 611 | $this->global->TAX_MODE_SELL_SERVICE = 'payment'; |
||
| 612 | if (empty($this->global->TAX_MODE_BUY_SERVICE)) |
||
| 613 | $this->global->TAX_MODE_BUY_SERVICE = 'payment'; |
||
| 614 | |||
| 615 | // Delay before warnings |
||
| 616 | // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx |
||
| 617 | if (isset($this->agenda)) {
|
||
| 618 | $this->adherent->subscription = new \stdClass(); |
||
| 619 | $this->adherent->subscription->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 24 * 60 * 60; |
||
| 620 | } |
||
| 621 | if (isset($this->agenda)) |
||
| 622 | $this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60; |
||
| 623 | if (isset($this->projet)) {
|
||
| 624 | $this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 24 * 60 * 60; |
||
| 625 | $this->projet->task = new StdClass(); |
||
| 626 | $this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 24 * 60 * 60; |
||
| 627 | } |
||
| 628 | |||
| 629 | if (isset($this->commande)) {
|
||
| 630 | $this->commande->client = new \stdClass(); |
||
| 631 | $this->commande->fournisseur = new \stdClass(); |
||
| 632 | $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 24 * 60 * 60; |
||
| 633 | $this->commande->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS : 7) * 24 * 60 * 60; |
||
| 634 | } |
||
| 635 | if (isset($this->propal)) {
|
||
| 636 | $this->propal->cloture = new \stdClass(); |
||
| 637 | $this->propal->facturation = new \stdClass(); |
||
| 638 | $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 24 * 60 * 60; |
||
| 639 | $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 24 * 60 * 60; |
||
| 640 | } |
||
| 641 | if (isset($this->facture)) {
|
||
| 642 | $this->facture->client = new \stdClass(); |
||
| 643 | $this->facture->fournisseur = new \stdClass(); |
||
| 644 | $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 24 * 60 * 60; |
||
| 645 | $this->facture->fournisseur->warning_delay = (isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY) ? $this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY : 0) * 24 * 60 * 60; |
||
| 646 | } |
||
| 647 | if (isset($this->contrat)) {
|
||
| 648 | $this->contrat->services = new \stdClass(); |
||
| 649 | $this->contrat->services->inactifs = new \stdClass(); |
||
| 650 | $this->contrat->services->expires = new \stdClass(); |
||
| 651 | $this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 24 * 60 * 60; |
||
| 652 | $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 24 * 60 * 60; |
||
| 653 | } |
||
| 654 | if (isset($this->commande)) {
|
||
| 655 | $this->bank->rappro = new \stdClass(); |
||
| 656 | $this->bank->cheque = new \stdClass(); |
||
| 657 | $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 24 * 60 * 60; |
||
| 658 | $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 24 * 60 * 60; |
||
| 659 | } |
||
| 660 | if (isset($this->expensereport)) {
|
||
| 661 | $this->expensereport->approve = new \stdClass(); |
||
| 662 | $this->expensereport->approve->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS) ? $this->global->MAIN_DELAY_EXPENSEREPORTS : 0) * 24 * 60 * 60; |
||
| 663 | $this->expensereport->payment = new \stdClass(); |
||
| 664 | $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 24 * 60 * 60; |
||
| 665 | } |
||
| 666 | |||
| 667 | if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) {
|
||
| 668 | $this->global->PRODUIT_MULTIPRICES_LIMIT = 5; |
||
| 669 | } |
||
| 670 | |||
| 671 | // For modules that want to disable top or left menu |
||
| 672 | if (!empty($this->global->MAIN_HIDE_TOP_MENU)) |
||
| 673 | $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU; |
||
| 674 | if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) |
||
| 675 | $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU; |
||
| 676 | |||
| 677 | if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) |
||
| 678 | $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3; |
||
| 679 | |||
| 680 | if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) |
||
| 681 | $this->global->THEME_HIDE_BORDER_ON_INPUT = 0; |
||
| 682 | |||
| 683 | // Save inconsistent option |
||
| 684 | if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
|
||
| 685 | $this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. |
||
| 686 | } |
||
| 687 | |||
| 688 | if (!isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) |
||
| 689 | $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1; |
||
| 690 | |||
| 691 | $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; |
||
| 692 | $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; |
||
| 693 | |||
| 694 | // For backward compatibility |
||
| 695 | if (isset($this->product)) |
||
| 696 | $this->produit = $this->product; |
||
| 697 | if (isset($this->facture)) |
||
| 698 | $this->invoice = $this->facture; |
||
| 699 | if (isset($this->commande)) |
||
| 700 | $this->order = $this->commande; |
||
| 701 | if (isset($this->contrat)) |
||
| 702 | $this->contract = $this->contrat; |
||
| 703 | if (isset($this->categorie)) |
||
| 704 | $this->category = $this->categorie; |
||
| 705 | |||
| 706 | // Object $mc |
||
| 707 | if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
|
||
| 708 | if (is_object($mc)) |
||
| 709 | $mc->setValues($this); |
||
| 710 | } |
||
| 711 | |||
| 712 | // We init log handlers |
||
| 713 | if (!empty($this->global->SYSLOG_HANDLERS)) {
|
||
| 714 | $handlers = json_decode($this->global->SYSLOG_HANDLERS); |
||
| 715 | } else {
|
||
| 716 | $handlers = array(); |
||
| 717 | } |
||
| 718 | |||
| 719 | foreach ($handlers as $handler) {
|
||
| 720 | $handler_files = array(); |
||
| 721 | $dirsyslogs = array_merge(array('/core/modules/syslog/'), $this->modules_parts['syslog']);
|
||
| 722 | foreach ($dirsyslogs as $reldir) {
|
||
| 723 | $dir = dol_buildpath($reldir, 0); |
||
| 724 | $newdir = dol_osencode($dir); |
||
| 725 | if (is_dir($newdir)) {
|
||
| 726 | $file = $newdir . $handler . '.php'; |
||
| 727 | if (file_exists($file)) {
|
||
| 728 | $handler_files[] = $file; |
||
| 729 | } |
||
| 730 | } |
||
| 731 | } |
||
| 732 | |||
| 733 | if (empty($handler_files)) {
|
||
| 734 | throw new Exception('Missing log handler file ' . $handler . '.php');
|
||
| 735 | } |
||
| 736 | |||
| 737 | require_once $handler_files[0]; |
||
| 738 | $loghandlerinstance = new $handler(); |
||
| 739 | if (!$loghandlerinstance instanceof LogHandlerInterface) {
|
||
| 740 | throw new Exception('Log handler does not extend LogHandlerInterface');
|
||
| 741 | } |
||
| 742 | |||
| 743 | if (empty($this->loghandlers[$handler])) {
|
||
| 744 | $this->loghandlers[$handler] = $loghandlerinstance; |
||
| 745 | } |
||
| 749 |