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