/** * pt * * @param DoliDB $db Database handler * @param string $sql SQL Request * @param string $date Date * @return void */ function pt($db, $sql, $date) { global $conf, $bc, $langs; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $total = 0; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print '<td class="nowrap" width="60%">' . $date . '</td>'; print '<td align="right">' . $langs->trans("Amount") . '</td>'; print '<td> </td>' . "\n"; print "</tr>\n"; $var = True; while ($i < $num) { $obj = $db->fetch_object($result); $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td class="nowrap">' . $obj->dm . "</td>\n"; $total = $total + $obj->mm; print '<td class="nowrap" align="right">' . price($obj->mm) . "</td><td > </td>\n"; print "</tr>\n"; $i++; } print '<tr class="liste_total"><td align="right">' . $langs->trans("Total") . " :</td><td class=\"nowrap\" align=\"right\"><b>" . price($total) . "</b></td><td> </td></tr>"; print "</table>"; $db->free($result); } else { dol_print_error($db); } }
/** * Load setup values into conf object (read llx_const) * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. * * @param DoliDB $db Database handler * @return int < 0 if KO, >= 0 if OK */ function setValues($db) { global $conf; dol_syslog(get_class($this) . "::setValues"); /* * Definition de toutes les constantes globales d'environnement * - En constante php (TODO a virer) * - En $this->global->key=value */ $sql = "SELECT " . $db->decrypt('name') . " as name,"; $sql .= " " . $db->decrypt('value') . " as value, entity"; $sql .= " FROM " . MAIN_DB_PREFIX . "const"; if (!empty($this->multicompany->transverse_mode)) { $sql .= " WHERE entity IN (0,1," . $this->entity . ")"; } else { $sql .= " WHERE entity IN (0," . $this->entity . ")"; } $sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite. $resql = $db->query($sql); if ($resql) { $i = 0; $numr = $db->num_rows($resql); while ($i < $numr) { $objp = $db->fetch_object($resql); $key = $objp->name; $value = $objp->value; if ($key) { if (!defined("{$key}")) { define("{$key}", $value); } // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install) $this->global->{$key} = $value; if ($value && preg_match('/^MAIN_MODULE_/', $key)) { // If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs']. if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) { $partname = 'tabs'; $params = explode(':', $value, 2); if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) { $modulename = strtolower($reg[1]); $partname = strtolower($reg[2]); if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); } $arrValue = json_decode($value, true); if (is_array($arrValue) && !empty($arrValue)) { $value = $arrValue; } else { if (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) { $value = '/' . $modulename . '/core/' . $partname . '/'; } else { if (in_array($partname, array('models', 'theme'))) { $value = '/' . $modulename . '/'; } else { if (in_array($partname, array('sms'))) { $value = $modulename; } else { if ($value == 1) { $value = '/' . $modulename . '/core/modules/' . $partname . '/'; } } } } } // ex: partname = societe $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) { $modulename = strtolower($reg[1]); if ($modulename == 'propale') { $modulename = 'propal'; } if (!isset($this->{$modulename}) || !is_object($this->{$modulename})) { $this->{$modulename} = new stdClass(); } $this->{$modulename}->enabled = true; $this->modules[] = $modulename; // Add this module in list of enabled modules } } } $i++; } $db->free($resql); } //var_dump($this->modules); //var_dump($this->modules_parts['theme']); // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. //$this->global->MAIN_SERVER_TZ='Europe/Paris'; if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') { try { date_default_timezone_set($this->global->MAIN_SERVER_TZ); } catch (Exception $e) { dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=" . $this->global->MAIN_SERVER_TZ, LOG_ERR); } } // Object $mc if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) { global $mc; $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); if ($ret) { $mc = new ActionsMulticompany($db); } } // Clean some variables if (empty($this->global->MAIN_MENU_STANDARD)) { $this->global->MAIN_MENU_STANDARD = "eldy_menu.php"; } if (empty($this->global->MAIN_MENUFRONT_STANDARD)) { $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php"; } 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 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 // Clean var use vat for company if (!isset($this->global->FACTURE_TVAOPTION)) { $this->global->FACTURE_TVAOPTION = 1; } else { if (!empty($this->global->FACTURE_TVAOPTION) && !is_numeric($this->global->FACTURE_TVAOPTION)) { // Old value of option, we clean to use new value (0 or 1) if ($this->global->FACTURE_TVAOPTION != "franchise") { $this->global->FACTURE_TVAOPTION = 1; } else { $this->global->FACTURE_TVAOPTION = 0; } } } // Variable globales LDAP if (empty($this->global->LDAP_FIELD_FULLNAME)) { $this->global->LDAP_FIELD_FULLNAME = ''; } if (!isset($this->global->LDAP_KEY_USERS)) { $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME; } if (!isset($this->global->LDAP_KEY_GROUPS)) { $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME; } if (!isset($this->global->LDAP_KEY_CONTACTS)) { $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME; } if (!isset($this->global->LDAP_KEY_MEMBERS)) { $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME; } // Load translation object with current language if (empty($this->global->MAIN_LANG_DEFAULT)) { $this->global->MAIN_LANG_DEFAULT = "en_US"; } // By default, we repeat info on all tabs if (!isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) { $this->global->MAIN_REPEATCONTACTONEACHTAB = 1; } if (!isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) { $this->global->MAIN_REPEATADDRESSONEACHTAB = 1; } $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // If multicompany module is enabled, we redefine the root of data if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1) { $rootfordata .= '/' . $this->entity; } // Define default dir_output and dir_temp for directories of modules foreach ($this->modules as $module) { // For multicompany sharings $this->{$module}->multidir_output = array($this->entity => $rootfordata . "/" . $module); $this->{$module}->multidir_temp = array($this->entity => $rootfordata . "/" . $module . "/temp"); // For backward compatibility $this->{$module}->dir_output = $rootfordata . "/" . $module; $this->{$module}->dir_temp = $rootfordata . "/" . $module . "/temp"; } // External modules storage if (!empty($this->modules_parts['dir'])) { foreach ($this->modules_parts['dir'] as $module => $dirs) { foreach ($dirs as $type => $name) { $subdir = $type == 'temp' ? '/temp' : ''; // For multicompany sharings $varname = 'multidir_' . $type; $this->{$module}->{$varname} = array($this->entity => $rootfordata . "/" . $name . $subdir); // For backward compatibility $varname = 'dir_' . $type; $this->{$module}->{$varname} = $rootfordata . "/" . $name . $subdir; } } } // For mycompany storage $this->mycompany->dir_output = $rootfordata . "/mycompany"; $this->mycompany->dir_temp = $rootfordata . "/mycompany/temp"; // For admin storage $this->admin->dir_output = $rootfordata . '/admin'; $this->admin->dir_temp = $rootfordata . '/admin/temp'; // For user storage $this->user->multidir_output = array($this->entity => $rootfordata . "/users"); $this->user->multidir_temp = array($this->entity => $rootfordata . "/users/temp"); // For backward compatibility $this->user->dir_output = $rootforuser . "/users"; $this->user->dir_temp = $rootforuser . "/users/temp"; // For propal storage $this->propal->dir_output = $rootfordata . "/propale"; $this->propal->dir_temp = $rootfordata . "/propale/temp"; // Exception: Some dir are not the name of module. So we keep exception here // for backward compatibility. // Sous module bons d'expedition $this->expedition_bon->enabled = defined("MAIN_SUBMODULE_EXPEDITION") ? MAIN_SUBMODULE_EXPEDITION : 0; // Sous module bons de livraison $this->livraison_bon->enabled = defined("MAIN_SUBMODULE_LIVRAISON") ? MAIN_SUBMODULE_LIVRAISON : 0; // Module fournisseur if (!empty($this->fournisseur)) { $this->fournisseur->commande = new stdClass(); $this->fournisseur->commande->dir_output = $rootfordata . "/fournisseur/commande"; $this->fournisseur->commande->dir_temp = $rootfordata . "/fournisseur/commande/temp"; $this->fournisseur->facture = new stdClass(); $this->fournisseur->facture->dir_output = $rootfordata . "/fournisseur/facture"; $this->fournisseur->facture->dir_temp = $rootfordata . "/fournisseur/facture/temp"; } // Module product/service $this->product->multidir_output = array($this->entity => $rootfordata . "/produit"); $this->product->multidir_temp = array($this->entity => $rootfordata . "/produit/temp"); $this->service->multidir_output = array($this->entity => $rootfordata . "/produit"); $this->service->multidir_temp = array($this->entity => $rootfordata . "/produit/temp"); // For backward compatibility $this->product->dir_output = $rootfordata . "/produit"; $this->product->dir_temp = $rootfordata . "/produit/temp"; $this->service->dir_output = $rootfordata . "/produit"; $this->service->dir_temp = $rootfordata . "/produit/temp"; // Module contrat $this->contrat->dir_output = $rootfordata . "/contracts"; $this->contrat->dir_temp = $rootfordata . "/contracts/temp"; // Set some default values // societe if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) { $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard"; } if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) { $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum"; } // Security if (empty($this->global->USER_PASSWORD_GENERATED)) { $this->global->USER_PASSWORD_GENERATED = 'standard'; } // Default password generator if (empty($this->global->MAIN_UMASK)) { $this->global->MAIN_UMASK = '0664'; } // Default mask // conf->use_javascript_ajax $this->use_javascript_ajax = 1; if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) { $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT; } // If no javascript_ajax, Ajax features are disabled. if (empty($this->use_javascript_ajax)) { unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT); unset($this->global->COMPANY_USE_SEARCH_TO_SELECT); unset($this->global->CONTACT_USE_SEARCH_TO_SELECT); unset($this->global->PROJECT_USE_SEARCH_TO_SELECT); } if (!empty($conf->productbatch->enabled)) { $this->global->STOCK_CALCULATE_ON_BILL = 0; $this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0; $this->global->STOCK_CALCULATE_ON_SHIPMENT = 1; $this->global->STOCK_CALCULATE_ON_SUPPLIER_BILL = 0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0; $this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1; } // conf->currency if (empty($this->global->MAIN_MONNAIE)) { $this->global->MAIN_MONNAIE = 'EUR'; } $this->currency = $this->global->MAIN_MONNAIE; // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) if (empty($this->global->ACCOUNTING_MODE)) { $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; } // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' // By default, suppliers objects can be linked to all projects $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1; // conf->liste_limit = constante de taille maximale des listes if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) { $this->global->MAIN_SIZE_LISTE_LIMIT = 25; } $this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT; // conf->product->limit_size = constante de taille maximale des select de produit if (!isset($this->global->PRODUIT_LIMIT_SIZE)) { $this->global->PRODUIT_LIMIT_SIZE = 100; } $this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE; // conf->theme et $this->css if (empty($this->global->MAIN_THEME)) { $this->global->MAIN_THEME = "eldy"; } if (!empty($this->global->MAIN_FORCETHEME)) { $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME; } $this->theme = $this->global->MAIN_THEME; $this->css = "/theme/" . $this->theme . "/style.css.php"; // conf->email_from = email pour envoi par dolibarr des mails automatiques $this->email_from = "*****@*****.**"; if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) { $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM; } // conf->notification->email_from = email pour envoi par Dolibarr des notifications $this->notification->email_from = $this->email_from; if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) { $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM; } // conf->mailing->email_from = email pour envoi par Dolibarr des mailings $this->mailing->email_from = $this->email_from; if (!empty($this->global->MAILING_EMAIL_FROM)) { $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM; } // Format for date (used by default when not found or not searched in lang) $this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions) $this->format_date_short_java = "dd/MM/yyyy"; // Format of day with Java tags $this->format_hour_short = "%H:%M"; $this->format_hour_short_duration = "%H:%M"; $this->format_date_text_short = "%d %b %Y"; $this->format_date_text = "%d %B %Y"; $this->format_date_hour_short = "%d/%m/%Y %H:%M"; $this->format_date_hour_sec_short = "%d/%m/%Y %H:%M:%S"; $this->format_date_hour_text_short = "%d %b %Y %H:%M"; $this->format_date_hour_text = "%d %B %Y %H:%M"; // Duration of workday if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) { $this->global->MAIN_DURATION_OF_WORKDAY = 86400; } // Limites decimales si non definie (peuvent etre egale a 0) if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) { $this->global->MAIN_MAX_DECIMALS_UNIT = 5; } if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) { $this->global->MAIN_MAX_DECIMALS_TOT = 2; } if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) { $this->global->MAIN_MAX_DECIMALS_SHOWN = 8; } // Default pdf use dash between lines if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) { $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; } // Set default value to MAIN_SHOW_LOGO if (!isset($this->global->MAIN_SHOW_LOGO)) { $this->global->MAIN_SHOW_LOGO = 1; } // Default max file size for upload $this->maxfilesize = empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024; // Define list of limited modules if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) { $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,askpricesupplier,facture,categorie,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda,adherent'; } // '' means 'all'. Note that contact is added here as it should be a module later. // Enable select2 if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT)) { $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2'; } // Timeouts if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) { $this->global->MAIN_USE_CONNECT_TIMEOUT = 10; } if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) { $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30; } // Set default variable to calculate VAT as if option tax_mode was 0 (standard) if (empty($this->global->TAX_MODE_SELL_PRODUCT)) { $this->global->TAX_MODE_SELL_PRODUCT = 'invoice'; } if (empty($this->global->TAX_MODE_BUY_PRODUCT)) { $this->global->TAX_MODE_BUY_PRODUCT = 'invoice'; } if (empty($this->global->TAX_MODE_SELL_SERVICE)) { $this->global->TAX_MODE_SELL_SERVICE = 'payment'; } if (empty($this->global->TAX_MODE_BUY_SERVICE)) { $this->global->TAX_MODE_BUY_SERVICE = 'payment'; } // Delay before warnings // Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx $this->propal->cloture = new stdClass(); $this->propal->facturation = new stdClass(); $this->commande->client = new stdClass(); $this->commande->fournisseur = new stdClass(); $this->facture->client = new stdClass(); $this->facture->fournisseur = new stdClass(); $this->contrat->services = new stdClass(); $this->contrat->services->inactifs = new stdClass(); $this->contrat->services->expires = new stdClass(); $this->adherent->cotisation = new stdClass(); $this->bank->rappro = new stdClass(); $this->bank->cheque = new stdClass(); $this->expensereport->payment = new stdClass(); $this->actions->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 24 * 60 * 60; $this->commande->client->warning_delay = (isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS) ? $this->global->MAIN_DELAY_ORDERS_TO_PROCESS : 2) * 24 * 60 * 60; $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; $this->propal->cloture->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE) ? $this->global->MAIN_DELAY_PROPALS_TO_CLOSE : 0) * 24 * 60 * 60; $this->propal->facturation->warning_delay = (isset($this->global->MAIN_DELAY_PROPALS_TO_BILL) ? $this->global->MAIN_DELAY_PROPALS_TO_BILL : 0) * 24 * 60 * 60; $this->facture->client->warning_delay = (isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED) ? $this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED : 0) * 24 * 60 * 60; $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; $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; $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 24 * 60 * 60; $this->adherent->cotisation->warning_delay = (isset($this->global->MAIN_DELAY_MEMBERS) ? $this->global->MAIN_DELAY_MEMBERS : 0) * 24 * 60 * 60; $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 24 * 60 * 60; $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 24 * 60 * 60; $this->expensereport->payment->warning_delay = (isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY) ? $this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY : 0) * 24 * 60 * 60; // For modules that want to disable top or left menu if (!empty($this->global->MAIN_HIDE_TOP_MENU)) { $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU; } if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) { $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU; } // For backward compatibility if (isset($this->product)) { $this->produit = $this->product; } if (isset($this->facture)) { $this->invoice = $this->facture; } if (isset($this->commande)) { $this->order = $this->commande; } if (isset($this->contrat)) { $this->contract = $this->contrat; } if (isset($this->categorie)) { $this->category = $this->categorie; } // Object $mc if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) { if (is_object($mc)) { $mc->setValues($this); } } // We init log handlers if (defined('SYSLOG_HANDLERS')) { $handlers = json_decode(constant('SYSLOG_HANDLERS')); } else { $handlers = array(); } foreach ($handlers as $handler) { $file = DOL_DOCUMENT_ROOT . '/core/modules/syslog/' . $handler . '.php'; if (!file_exists($file)) { throw new Exception('Missing log handler file ' . $handler . '.php'); } require_once $file; $loghandlerinstance = new $handler(); if (!$loghandlerinstance instanceof LogHandlerInterface) { throw new Exception('Log handler does not extend LogHandlerInterface'); } if (empty($conf->loghandlers[$handler])) { $this->loghandlers[$handler] = $loghandlerinstance; } } }
/** * Retrieve all batch number details link to a shipment line * * @param DoliDB $db Database object * @param int $id_line_expdet id of shipment line * @return variant -1 if KO, array of ExpeditionLineBatch if OK */ static function fetchAll($db, $id_line_expdet) { $sql = "SELECT rowid,"; $sql .= "fk_expeditiondet"; $sql .= ", sellby"; $sql .= ", eatby"; $sql .= ", batch"; $sql .= ", qty"; $sql .= ", fk_origin_stock"; $sql .= " FROM " . MAIN_DB_PREFIX . self::$_table_element; $sql .= " WHERE fk_expeditiondet=" . (int) $id_line_expdet; dol_syslog(__METHOD__ . "", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $tmp = new self($db); $obj = $db->fetch_object($resql); $tmp->sellby = $db->jdate($obj->sellby); $tmp->eatby = $db->jdate($obj->eatby); $tmp->batch = $obj->batch; $tmp->id = $obj->rowid; $tmp->fk_origin_stock = $obj->fk_origin_stock; $tmp->fk_expeditiondet = $obj->fk_expeditiondet; $tmp->dluo_qty = $obj->qty; $ret[] = $tmp; $i++; } $db->free($resql); return $ret; } else { return -1; } }
/** * Return HTML table with list of projects and number of opened tasks * * @param DoliDB $db Database handler * @param int $socid Id thirdparty * @param int $projectsListId Id of project i have permission on * @param int $mytasks Limited to task i am contact to * @return void */ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks = 0) { global $langs, $conf, $user, $bc; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $projectstatic = new Project($db); $sortfield = ''; $sortorder = ''; print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("Project"), "index.php", "", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print "</tr>\n"; $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, COUNT(t.rowid) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p"; if ($mytasks) { $sql .= ", " . MAIN_DB_PREFIX . "projet_task as t"; $sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec"; $sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet"; } $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.rowid IN (" . $projectsListId . ")"; if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; } if ($mytasks) { $sql .= " AND p.rowid = t.fk_projet"; $sql .= " AND ec.element_id = t.rowid"; $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; $sql .= " AND ctc.element = 'project_task'"; $sql .= " AND ec.fk_socpeople = " . $user->id; } $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut"; $sql .= " ORDER BY p.title, p.ref"; $var = true; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $projectstatic->id = $objp->projectid; $projectstatic->user_author_id = $objp->fk_user_creat; $projectstatic->public = $objp->public; // Check is user has read permission on project $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td class="nowrap">'; $projectstatic->ref = $objp->ref; print $projectstatic->getNomUrl(1); print ' - ' . dol_trunc($objp->title, 24) . '</td>'; print '<td align="right">' . $objp->nb . '</td>'; $projectstatic->statut = $objp->fk_statut; print '<td align="right">' . $projectstatic->getLibStatut(3) . '</td>'; print "</tr>\n"; } $i++; } $db->free($resql); } else { dol_print_error($db); } print "</table>"; }
/** * Return HTML table with list of projects and number of opened tasks * * @param DoliDB $db Database handler * @param Form $form Object form * @param int $socid Id thirdparty * @param int $projectsListId Id of project i have permission on * @param int $mytasks Limited to task i am contact to * @param int $statut -1=No filter on statut, 0 or 1 = Filter on status * @param array $listofoppstatus List of opportunity status * @return void */ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array()) { global $langs, $conf, $user, $bc; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $projectstatic = new Project($db); $sortfield = ''; $sortorder = ''; $project_year_filter = 0; $title = $langs->trans("Projects"); if (strcmp($statut, '') && $statut >= 0) { $title = $langs->trans("Projects") . ' ' . $langs->trans($projectstatic->statuts_long[$statut]); } print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print_liste_field_titre($title, "index.php", "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print_liste_field_titre($langs->trans("OpportunityAmount"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("OpportunityStatus"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print "</tr>\n"; $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount, COUNT(DISTINCT t.rowid) as nb"; // We use DISTINCT here because line can be doubled if task has 2 links to same user $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p"; if ($mytasks) { $sql .= ", " . MAIN_DB_PREFIX . "projet_task as t"; $sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec"; $sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet"; } $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.rowid IN (" . $projectsListId . ")"; if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; } if ($mytasks) { $sql .= " AND p.rowid = t.fk_projet"; $sql .= " AND ec.element_id = t.rowid"; $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; $sql .= " AND ctc.element = 'project_task'"; $sql .= " AND ec.fk_socpeople = " . $user->id; } if ($statut >= 0) { $sql .= " AND p.fk_statut = " . $statut; } if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { $project_year_filter = GETPOST("project_year_filter"); //Check if empty or invalid year. Wildcard ignores the sql check if ($project_year_filter != "*") { if (empty($project_year_filter) || !ctype_digit($project_year_filter)) { $project_year_filter = date("Y"); } $sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")"; $sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")"; } } $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount"; $sql .= " ORDER BY p.title, p.ref"; $var = true; $resql = $db->query($sql); if ($resql) { $total_task = 0; $total_opp_amount = 0; $ponderated_opp_amount = 0; $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $projectstatic->id = $objp->projectid; $projectstatic->user_author_id = $objp->fk_user_creat; $projectstatic->public = $objp->public; // Check is user has read permission on project $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td class="nowrap">'; $projectstatic->ref = $objp->ref; print $projectstatic->getNomUrl(1); print ' - ' . dol_trunc($objp->title, 24) . '</td>'; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td align="right">'; if ($objp->opp_amount) { print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); } print '</td>'; print '<td align="right">'; $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); if ($code) { print $langs->trans("OppStatus" . $code); } print '</td>'; } $projectstatic->statut = $objp->status; if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<td align="right">' . $objp->nb . '</td>'; } print '<td align="right">' . $projectstatic->getLibStatut(3) . '</td>'; print "</tr>\n"; $total_task = $total_task + $objp->nb; $total_opp_amount = $total_opp_amount + $objp->opp_amount; $ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100); } $i++; } print '<tr><td>' . $langs->trans("Total") . "</td>"; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td align="right">' . price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency) . '</td>'; print '<td align="right">' . $form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmount"), 1) . '</td>'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<td align="right">' . $total_task . '</td>'; } $db->free($resql); } else { dol_print_error($db); } print "</table>"; if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { //Add the year filter input print '<form method="get" action="' . $_SERVER["PHP_SELF"] . '">'; print '<table width="100%">'; print '<tr>'; print '<td>' . $langs->trans("Year") . '</td>'; print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="' . $project_year_filter . '"/>'; print "</tr>\n"; print '</table></form>'; } }
/** * Return if a code is used (by other element) * * @param DoliDB $db Handler acces base * @param string $code Code a verifier * @param Product $product Objet product * @return int 0 if available, <0 if KO */ function verif_dispo($db, $code, $product) { $sql = "SELECT barcode FROM " . MAIN_DB_PREFIX . "product"; $sql .= " WHERE barcode = '" . $code . "'"; if ($product->id > 0) { $sql .= " AND rowid <> " . $product->id; } $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { return 0; } else { return -1; } } else { return -2; } }
/** * Return all batch detail records for given product and warehouse * * @param DoliDB $db database object * @param int $fk_product_stock id product_stock for objet * @param int $with_qty doesn't return line with 0 quantity * @return int <0 if KO, >0 if OK */ public static function findAll($db, $fk_product_stock, $with_qty = 0) { global $langs; $ret = array(); $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.tms,"; $sql .= " t.fk_product_stock,"; $sql .= " t.sellby,"; $sql .= " t.eatby,"; $sql .= " t.batch,"; $sql .= " t.qty,"; $sql .= " t.import_key"; $sql .= " FROM " . MAIN_DB_PREFIX . "product_batch as t"; $sql .= " WHERE fk_product_stock=" . $fk_product_stock; if ($with_qty) { $sql .= " AND qty<>0"; } dol_syslog("productbatch::findAll", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); $tmp = new productbatch($db); $tmp->id = $obj->rowid; $tmp->tms = $db->jdate($obj->tms); $tmp->fk_product_stock = $obj->fk_product_stock; $tmp->sellby = $db->jdate($obj->sellby); $tmp->eatby = $db->jdate($obj->eatby); $tmp->batch = $obj->batch; $tmp->qty = $obj->qty; $tmp->import_key = $obj->import_key; array_push($ret, $tmp); $i++; } $db->free($resql); return $ret; } else { $error = "Error " . $db->lasterror(); return -1; } }
/** * Return list of activated modules usable for document generation * * @param DoliDB $db Database handler * @param string $type Type of models (company, invoice, ...) * @param int $maxfilenamelength Max length of value to show * @return mixed 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename". */ function getListOfModels($db, $type, $maxfilenamelength = 0) { global $conf, $langs; $liste = array(); $found = 0; $dirtoscan = ''; $sql = "SELECT nom as id, nom as lib, libelle as label, description as description"; $sql .= " FROM " . MAIN_DB_PREFIX . "document_model"; $sql .= " WHERE type = '" . $type . "'"; $sql .= " AND entity in (0," . $conf->entity . ")"; //print $sql; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $found = 1; $obj = $db->fetch_object($resql); // If this generation module needs to scan a directory, then description field is filled // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...). if (!empty($obj->description)) { include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $const = $obj->description; $dirtoscan .= ($dirtoscan ? ',' : '') . preg_replace('/[\\r\\n]+/', ',', trim($conf->global->{$const})); $listoffiles = array(); // Now we add models found in directories scanned $listofdir = explode(',', $dirtoscan); foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); if ($conf->multicompany->enabled && $conf->entity > 1) { $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT . "/" . $conf->entity, $tmpdir); } else { $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); } if (!$tmpdir) { unset($listofdir[$key]); continue; } if (is_dir($tmpdir)) { $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\\.odt'); if (count($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } } } if (count($listoffiles)) { foreach ($listoffiles as $record) { $max = $maxfilenamelength ? $maxfilenamelength : 28; $liste[$obj->id . ':' . $record['fullname']] = dol_trunc($record['name'], $max, 'middle'); } } else { $liste[0] = $obj->label . ': ' . $langs->trans("None"); } } else { $liste[$obj->id] = $obj->label ? $obj->label : $obj->lib; } $i++; } } else { dol_print_error($db); return -1; } if ($found) { return $liste; } else { return 0; } }
/** * Show html area for list of subsidiaries * * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Database handler * @param Societe $object Third party object * @return void */ function show_subsidiaries($conf, $langs, $db, $object) { global $user; global $bc; $i = -1; $sql = "SELECT s.rowid, s.nom as name, s.address, s.zip, s.town, s.code_client, s.canvas"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= " WHERE s.parent = " . $object->id; $sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")"; $sql .= " ORDER BY s.nom"; $result = $db->query($sql); $num = $db->num_rows($result); if ($num) { $socstatic = new Societe($db); print_titre($langs->trans("Subsidiaries")); print "\n" . '<table class="noborder" width="100%">' . "\n"; print '<tr class="liste_titre"><td>' . $langs->trans("Company") . '</td>'; print '<td>' . $langs->trans("Address") . '</td><td>' . $langs->trans("Zip") . '</td>'; print '<td>' . $langs->trans("Town") . '</td><td>' . $langs->trans("CustomerCode") . '</td>'; print "<td> </td>"; print "</tr>"; $i = 0; $var = true; while ($i < $num) { $obj = $db->fetch_object($result); $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td>'; $socstatic->id = $obj->rowid; $socstatic->name = $obj->name; $socstatic->canvas = $obj->canvas; print $socstatic->getNomUrl(1); print '</td>'; print '<td>' . $obj->address . '</td>'; print '<td>' . $obj->zip . '</td>'; print '<td>' . $obj->town . '</td>'; print '<td>' . $obj->code_client . '</td>'; print '<td align="center">'; print '<a href="' . DOL_URL_ROOT . '/societe/soc.php?socid=' . $obj->rowid . '&action=edit">'; print img_edit(); print '</a></td>'; print "</tr>\n"; $i++; } print "\n</table>\n"; } print "<br>\n"; return $i; }
/** * Renvoi si un code est pris ou non (par autre tiers) * * @param DoliDB $db Handler acces base * @param string $code Code a verifier * @param Societe $soc Objet societe * @return int 0 if available, <0 if KO */ function verif_dispo($db, $code, $soc) { $sql = "SELECT code_client FROM " . MAIN_DB_PREFIX . "societe"; $sql .= " WHERE code_client = '" . $code . "'"; if ($soc->id > 0) { $sql .= " AND rowid <> " . $soc->id; } $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { return 0; } else { return -1; } } else { return -2; } }
/** * Return if a code is available * * @param DoliDB $db Database handler * @param string $code Code of third party * @param Societe $societe Object third party * @param string $type 'supplier' or 'customer' * @return int 0 if OK but not available, >0 if OK and available, <0 if KO */ function verif($db, $code, $societe, $type) { $sql = "SELECT "; if ($type == 'customer') { $sql .= "code_compta"; } else { if ($type == 'supplier') { $sql .= "code_compta_fournisseur"; } } $sql .= " FROM " . MAIN_DB_PREFIX . "societe"; $sql .= " WHERE "; if ($type == 'customer') { $sql .= "code_compta"; } else { if ($type == 'supplier') { $sql .= "code_compta_fournisseur"; } } $sql .= " = '" . $this->db->escape($code) . "'"; if (!empty($societe->id)) { $sql .= " AND rowid <> " . $societe->id; } $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { dol_syslog("mod_codecompta_aquarium::verif code '" . $code . "' available"); return 1; // Dispo } else { dol_syslog("mod_codecompta_aquarium::verif code '" . $code . "' not available"); return 0; // Non dispo } } else { $this->error = $db->error() . " sql=" . $sql; dol_syslog("mod_codecompta_aquarium::verif error" . $this->error, LOG_ERR); return -1; // Erreur } }
/** * Migrate event assignement to owner * * @param DoliDB $db Database handler * @param Translate $langs Object langs * @param Conf $conf Object conf * @return void */ function migrate_event_assignement($db, $langs, $conf) { print '<tr><td colspan="4">'; print '<br>'; print '<b>' . $langs->trans('MigrationEvents') . "</b><br>\n"; $error = 0; dolibarr_install_syslog("upgrade2::migrate_event_assignement"); $db->begin(); $sqlSelect = "SELECT a.id, a.fk_user_action"; $sqlSelect .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a"; $sqlSelect .= " LEFT JOIN " . MAIN_DB_PREFIX . "actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action"; $sqlSelect .= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM " . MAIN_DB_PREFIX . "actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')"; $sqlSelect .= " ORDER BY a.id"; //print $sqlSelect; $resql = $db->query($sqlSelect); if ($resql) { $i = 0; $num = $db->num_rows($resql); if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "INSERT INTO " . MAIN_DB_PREFIX . "actioncomm_resources(fk_actioncomm, element_type, fk_element) "; $sqlUpdate .= "VALUES(" . $obj->id . ", 'user', " . $obj->fk_user_action . ")"; $result = $db->query($sqlUpdate); if (!$result) { $error++; dol_print_error($db); } print ". "; $i++; } } else { print $langs->trans('AlreadyDone') . "<br>\n"; } if (!$error) { $db->commit(); } else { $db->rollback(); } } else { dol_print_error($db); $db->rollback(); } print '</td></tr>'; }
/** * Return array of boxes qualified for area and user * * @param DoliDB $db Database handler * @param string $mode 'available' or 'activated' * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) * @param User $user Objet user to filter (used only if $zone >= 0) * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude * @return array Array of boxes */ static function listBoxes($db, $mode, $zone, $user, $excludelist = array()) { global $conf; $boxes = array(); $confuserzone = 'MAIN_BOXES_' . $zone; if ($mode == 'activated') { $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; $sql .= " d.rowid as box_id, d.file, d.note, d.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "boxes as b, " . MAIN_DB_PREFIX . "boxes_def as d"; $sql .= " WHERE b.box_id = d.rowid"; $sql .= " AND d.entity = " . $conf->entity; if ($zone >= 0) { $sql .= " AND b.position = " . $zone; } if ($user->id && $user->conf->{$confuserzone}) { $sql .= " AND b.fk_user = "******" AND b.fk_user = 0"; } $sql .= " ORDER BY b.box_order"; } else { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "boxes_def as d"; $sql .= " WHERE entity = " . $conf->entity; } $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $j = 0; while ($j < $num) { $obj = $db->fetch_object($resql); if (!in_array($obj->box_id, $excludelist)) { if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) { $boxname = $regs[1]; $module = $regs[2]; $relsourcefile = "/" . $module . "/core/boxes/" . $boxname . ".php"; } else { $boxname = preg_replace('/.php$/i', '', $obj->file); $relsourcefile = "/core/boxes/" . $boxname . ".php"; } dol_include_once($relsourcefile); if (class_exists($boxname)) { $box = new $boxname($db, $obj->note); // box properties $box->rowid = !empty($obj->rowid) ? $obj->rowid : ''; $box->id = !empty($obj->box_id) ? $obj->box_id : ''; $box->position = !empty($obj->position) ? $obj->position : ''; $box->box_order = !empty($obj->box_order) ? $obj->box_order : ''; $box->fk_user = !empty($obj->fk_user) ? $obj->fk_user : ''; $box->sourcefile = $relsourcefile; if ($mode == 'activated' && (!$user->id || !$user->conf->{$confuserzone})) { if (is_numeric($box->box_order)) { if ($box->box_order % 2 == 1) { $box->box_order = 'A' . $box->box_order; } elseif ($box->box_order % 2 == 0) { $box->box_order = 'B' . $box->box_order; } } } // box_def properties $box->box_id = !empty($obj->box_id) ? $obj->box_id : ''; $box->note = !empty($obj->note) ? $obj->note : ''; $enabled = true; if (isset($box->depends) && count($box->depends) > 0) { foreach ($box->depends as $module) { //print $boxname.'-'.$module.'<br>'; if (empty($conf->{$module}->enabled)) { $enabled = false; } } } if ($enabled) { $boxes[] = $box; } } } $j++; } } else { //dol_print_error($db); $this->error = $db->error(); dol_syslog(get_class() . "::listBoxes Error " . $this->error, LOG_ERR); return array(); } return $boxes; }
/** * Migrate link stored into fk_mode_reglement * * @param DoliDB $db Database handler * @param Translate $langs Object langs * @param Conf $conf Object conf * @return void */ function migrate_mode_reglement($db,$langs,$conf) { print '<tr><td colspan="4">'; print '<br>'; print '<b>'.$langs->trans('MigrationPaymentMode')."</b><br>\n"; $elements = array( 'old_id' => array(5,8,9,10,11), 'new_id' => array(50,51,52,53,54), 'code' => array('VAD','TRA','LCR','FAC','PRO'), 'tables' => array('commande_fournisseur','commande','facture_rec','facture','propal') ); $count=0; foreach($elements['old_id'] as $key => $old_id) { $error=0; dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]); $sqlSelect = "SELECT id"; $sqlSelect.= " FROM ".MAIN_DB_PREFIX."c_paiement"; $sqlSelect.= " WHERE id = ".$old_id; $sqlSelect.= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sqlSelect); if ($resql) { $num = $db->num_rows($resql); if ($num) { $count++; $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET "; $sql.= "id = ".$elements['new_id'][$key]; $sql.= " WHERE id = ".$old_id; $sql.= " AND code = '".$elements['code'][$key]."'"; $resql = $db->query($sql); if ($resql) { foreach($elements['tables'] as $table) { $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; $sql.= "fk_mode_reglement = ".$elements['new_id'][$key]; $sql.= " WHERE fk_mode_reglement = ".$old_id; $resql = $db->query($sql); if (! $resql) { dol_print_error($db); $error++; } print ". "; } if (! $error) { $db->commit(); } else { dol_print_error($db); $db->rollback(); } } else { dol_print_error($db); $db->rollback(); } } } } if ($count == 0) print $langs->trans('AlreadyDone')."<br>\n"; print '</td></tr>'; }
/** * Migrate categorie association * * @param DoliDB $db Database handler * @param Translate $langs Object langs * @param Conf $conf Object conf * @return void */ function migrate_categorie_association($db, $langs, $conf) { print '<tr><td colspan="4">'; print '<br>'; print '<b>' . $langs->trans('MigrationCategorieAssociation') . "</b><br>\n"; $error = 0; if ($db->DDLInfoTable(MAIN_DB_PREFIX . "categorie_association")) { dolibarr_install_syslog("upgrade2::migrate_categorie_association"); $db->begin(); $sqlSelect = "SELECT fk_categorie_mere, fk_categorie_fille"; $sqlSelect .= " FROM " . MAIN_DB_PREFIX . "categorie_association"; $resql = $db->query($sqlSelect); if ($resql) { $i = 0; $num = $db->num_rows($resql); if ($num) { while ($i < $num) { $obj = $db->fetch_object($resql); $sqlUpdate = "UPDATE " . MAIN_DB_PREFIX . "categorie SET "; $sqlUpdate .= "fk_parent = " . $obj->fk_categorie_mere; $sqlUpdate .= " WHERE rowid = " . $obj->fk_categorie_fille; $result = $db->query($sqlUpdate); if (!$result) { $error++; dol_print_error($db); } print ". "; $i++; } } else { print $langs->trans('AlreadyDone') . "<br>\n"; } if (!$error) { // TODO DROP table in the next release /* $sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."categorie_association"; if ($db->query($sqlDrop)) { $db->commit(); } else { $db->rollback(); } */ $db->commit(); } else { $db->rollback(); } } else { dol_print_error($db); $db->rollback(); } } else { print $langs->trans('AlreadyDone') . "<br>\n"; } print '</td></tr>'; }
/** * Return array of boxes qualified for area and user * * @param DoliDB $db Database handler * @param string $mode 'available' or 'activated' * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) * @param User|null $user Object user to filter * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude * @return array Array of boxes */ static function listBoxes($db, $mode, $zone, $user = null, $excludelist = array()) { global $conf; $boxes = array(); $confuserzone = 'MAIN_BOXES_' . $zone; if ($mode == 'activated') { $sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,"; $sql .= " d.rowid as box_id, d.file, d.note, d.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "boxes as b, " . MAIN_DB_PREFIX . "boxes_def as d"; $sql .= " WHERE b.box_id = d.rowid"; $sql .= " AND b.entity IN (0," . (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) ? "1," : "") . $conf->entity . ")"; if ($zone >= 0) { $sql .= " AND b.position = " . $zone; } if (is_object($user)) { $sql .= " AND b.fk_user IN (0," . $user->id . ")"; } else { $sql .= " AND b.fk_user = 0"; } $sql .= " ORDER BY b.box_order"; } else { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "boxes_def as d"; $sql .= " WHERE d.entity IN (0," . (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) ? "1," : "") . $conf->entity . ")"; } dol_syslog(get_class() . "::listBoxes get default box list for mode=" . $mode . " userid=" . (is_object($user) ? $user->id : '') . "", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $j = 0; while ($j < $num) { $obj = $db->fetch_object($resql); if (!in_array($obj->box_id, $excludelist)) { if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) { $boxname = preg_replace('/\\.php$/i', '', $regs[1]); $module = $regs[2]; $relsourcefile = "/" . $module . "/core/boxes/" . $boxname . ".php"; } else { $boxname = preg_replace('/\\.php$/i', '', $obj->file); $relsourcefile = "/core/boxes/" . $boxname . ".php"; } //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'<br>'; // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then // the "enabled" condition for modules forbidden for external users and the depends condition can be done. // Goal is to avoid making a "new" done for each boxes returned by select. dol_include_once($relsourcefile); if (class_exists($boxname)) { $box = new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. //$box=new stdClass(); // box properties $box->rowid = empty($obj->rowid) ? '' : $obj->rowid; $box->id = empty($obj->box_id) ? '' : $obj->box_id; $box->position = $obj->position == '' ? '' : $obj->position; // '0' must staty '0' $box->box_order = empty($obj->box_order) ? '' : $obj->box_order; $box->fk_user = empty($obj->fk_user) ? 0 : $obj->fk_user; $box->sourcefile = $relsourcefile; $box->class = $boxname; if ($mode == 'activated' && !is_object($user)) { if (is_numeric($box->box_order)) { if ($box->box_order % 2 == 1) { $box->box_order = 'A' . $box->box_order; } elseif ($box->box_order % 2 == 0) { $box->box_order = 'B' . $box->box_order; } } } // box_def properties $box->box_id = empty($obj->box_id) ? '' : $obj->box_id; $box->note = empty($obj->note) ? '' : $obj->note; // Filter on box->enabled (used for example by box_comptes) // Filter also on box->depends. Example: array("product|service") or array("contrat", "service") $enabled = $box->enabled; if (isset($box->depends) && count($box->depends) > 0) { foreach ($box->depends as $moduleelem) { $arrayelem = explode('|', $moduleelem); $tmpenabled = 0; // $tmpenabled is used for the '|' test (OR) foreach ($arrayelem as $module) { $tmpmodule = preg_replace('/@[^@]+/', '', $module); if (!empty($conf->{$tmpmodule}->enabled)) { $tmpenabled = 1; } //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>'; } if (empty($tmpenabled)) { $enabled = 0; break; } } } //print '=>'.$boxname.'-enabled='.$enabled.'<br>'; //print 'xx module='.$module.' enabled='.$enabled; if ($enabled) { $boxes[] = $box; } else { unset($box); } } else { dol_syslog("Failed to load box '" . $boxname . "' into file '" . $relsourcefile . "'", LOG_WARNING); } } $j++; } } else { dol_syslog($db->lasterror(), LOG_ERR); return array('error' => $db->lasterror()); } return $boxes; }
/** * Renvoi la liste des modeles de numérotation * * @param DoliDB $db Database handler * @param string $maxfilenamelength Max length of value to show * @return array List of numbers */ static function liste_modeles($db, $maxfilenamelength = 0) { $liste = array(); $sql = ""; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); $liste[$row[0]] = $row[1]; $i++; } } else { return -1; } return $liste; }
/** * Clean corrupted tree (orphelins linked to a not existing parent), record linked to themself and child-parent loop * * @param DoliDB $db Database handler * @param string $tabletocleantree Table to clean * @param string $fieldfkparent Field name that contains id of parent * @return int Nb of records fixed/deleted */ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) { $totalnb = 0; $listofid = array(); $listofparentid = array(); // Get list of all id in array listofid and all parents in array listofparentid $sql = 'SELECT rowid, ' . $fieldfkparent . ' as parent_id FROM ' . MAIN_DB_PREFIX . $tabletocleantree; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); $listofid[] = $obj->rowid; if ($obj->parent_id > 0) { $listofparentid[$obj->rowid] = $obj->parent_id; } $i++; } } else { dol_print_error($db); } if (count($listofid)) { print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.' . "<br>\n"; // Check loops on each other $sql = "UPDATE " . MAIN_DB_PREFIX . $tabletocleantree . " SET " . $fieldfkparent . " = 0 WHERE " . $fieldfkparent . " = rowid"; // So we update only records linked to themself $resql = $db->query($sql); if ($resql) { $nb = $db->affected_rows($sql); if ($nb > 0) { print '<br>Some record that were parent of themself were cleaned.'; } $totalnb += $nb; } //else dol_print_error($db); // Check other loops $listofidtoclean = array(); foreach ($listofparentid as $id => $pid) { // Check depth //print 'Analyse record id='.$id.' with parent '.$pid.'<br>'; $cursor = $id; $arrayidparsed = array(); // We start from child $id while ($cursor > 0) { $arrayidparsed[$cursor] = 1; if ($arrayidparsed[$listofparentid[$cursor]]) { print 'Found a loop between id ' . $id . ' - ' . $cursor . '<br>'; unset($arrayidparsed); $listofidtoclean[$cursor] = $id; break; } $cursor = $listofparentid[$cursor]; } if (count($listofidtoclean)) { break; } } $sql = "UPDATE " . MAIN_DB_PREFIX . $tabletocleantree; $sql .= " SET " . $fieldfkparent . " = 0"; $sql .= " WHERE rowid IN (" . join(',', $listofidtoclean) . ")"; // So we update only records detected wrong $resql = $db->query($sql); if ($resql) { $nb = $db->affected_rows($sql); if ($nb > 0) { // Removed orphelins records print '<br>Some records were detected to have parent that is a child, we set them as root record for id: '; print join(',', $listofidtoclean); } $totalnb += $nb; } //else dol_print_error($db); // Check and clean orphelins $sql = "UPDATE " . MAIN_DB_PREFIX . $tabletocleantree; $sql .= " SET " . $fieldfkparent . " = 0"; $sql .= " WHERE " . $fieldfkparent . " NOT IN (" . join(',', $listofid) . ")"; // So we update only records linked to a non existing parent $resql = $db->query($sql); if ($resql) { $nb = $db->affected_rows($sql); if ($nb > 0) { // Removed orphelins records print '<br>Some orphelins were found and modified to be parent so records are visible again for id: '; print join(',', $listofid); } $totalnb += $nb; } //else dol_print_error($db); print '<br>We fixed ' . $totalnb . ' record(s). Some records may still be corrupted. New check may be required.'; return $totalnb; } }
/** * Core function to output left menu auguria * * @param DoliDB $db Database handler * @param array $menu_array_before Table of menu entries to show before entries of menu handler * @param array $menu_array_after Table of menu entries to show after entries of menu handler * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param Menu $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all) * @param array $moredata An array with more data to output * @return int Nb of entries */ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null) { global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc; $newmenu = $menu; $mainmenu = $forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]; $leftmenu = $forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]); // Show logo company if (empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $mysoc->logo_mini = $conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; if (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_mini)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode('thumbs/' . $mysoc->logo_mini); } else { $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; } $title = $langs->trans("GoIntoSetupToChangeLogo"); print "\n" . '<!-- Show logo on menu -->' . "\n"; print '<div class="blockvmenuimpair blockvmenulogo">' . "\n"; print '<div class="menu_titre" id="menu_titre_logo"></div>'; print '<div class="menu_top" id="menu_top_logo"></div>'; print '<div class="menu_contenu" id="menu_contenu_logo">'; print '<div class="center"><img title="' . dol_escape_htmltag($title) . '" alt="" src="' . $urllogo . '" style="max-width: 80%"></div>' . "\n"; print '</div>'; print '<div class="menu_end" id="menu_end_logo"></div>'; print '</div>' . "\n"; } if (is_array($moredata) && !empty($moredata['searchform'])) { print "\n"; print "<!-- Begin SearchForm -->\n"; print '<div id="blockvmenusearch" class="blockvmenusearch">' . "\n"; print $moredata['searchform']; print '</div>' . "\n"; print "<!-- End SearchForm -->\n"; } // We update newmenu with entries found into database $menuArbo = new Menubase($db, 'auguria'); $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, $user->societe_id ? 1 : 0, 'auguria', $tabMenu); // We update newmenu for special dynamic menus if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') { $sql = "SELECT rowid, label, courant, rappro, courant"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; $sql .= " WHERE entity = " . $conf->entity; $sql .= " AND clos = 0"; $sql .= " ORDER BY label"; $resql = $db->query($sql); if ($resql) { $numr = $db->num_rows($resql); $i = 0; if ($numr > 0) { $newmenu->add('/compta/bank/index.php', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire); } while ($i < $numr) { $objp = $db->fetch_object($resql); $newmenu->add('/compta/bank/card.php?id=' . $objp->rowid, $objp->label, 1, $user->rights->banque->lire); if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) { $newmenu->add('/compta/bank/rappro.php?account=' . $objp->rowid, $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate); } $i++; } } else { dol_print_error($db); } $db->free($resql); } if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') { $newmenu->add('/accountancy/journal/index.php?leftmenu=journal', $langs->trans("Journaux"), 0, $user->rights->banque->lire); if ($leftmenu == 'journal') { $sql = "SELECT rowid, label, accountancy_journal"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; $sql .= " WHERE entity = " . $conf->entity; $sql .= " AND clos = 0"; $sql .= " ORDER BY label"; $resql = $db->query($sql); if ($resql) { $numr = $db->num_rows($resql); $i = 0; if ($numr > 0) { while ($i < $numr) { $objp = $db->fetch_object($resql); $newmenu->add('/accountancy/journal/bankjournal.php?id_account=' . $objp->rowid, $langs->trans("Journal") . ' - ' . $objp->label, 1, $user->rights->accounting->comptarapport->lire); $i++; } } } else { dol_print_error($db); } $db->free($resql); // Add other journal $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal", $langs->trans("SellsJournal"), 1, $user->rights->accounting->comptarapport->lire); $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal", $langs->trans("PurchasesJournal"), 1, $user->rights->accounting->comptarapport->lire); } } if ($conf->ftp->enabled && $mainmenu == 'ftp') { $MAXFTP = 20; $i = 1; while ($i <= $MAXFTP) { $paramkey = 'FTP_NAME_' . $i; //print $paramkey; if (!empty($conf->global->{$paramkey})) { $link = "/ftp/index.php?idmenu=" . $_SESSION["idmenu"] . "&numero_ftp=" . $i; $newmenu->add($link, dol_trunc($conf->global->{$paramkey}, 24)); } $i++; } } // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after //var_dump($menu_array_before);exit; //var_dump($menu_array_after);exit; $menu_array = $newmenu->liste; if (is_array($menu_array_before)) { $menu_array = array_merge($menu_array_before, $menu_array); } if (is_array($menu_array_after)) { $menu_array = array_merge($menu_array, $menu_array_after); } //var_dump($menu_array);exit; if (!is_array($menu_array)) { return 0; } // Show menu if (empty($noout)) { $alt = 0; $altok = 0; $blockvmenuopened = false; $num = count($menu_array); for ($i = 0; $i < $num; $i++) { $showmenu = true; if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) { $showmenu = false; } $alt++; if (empty($menu_array[$i]['level']) && $showmenu) { $altok++; $blockvmenuopened = true; if ($altok % 2 == 0) { print '<div class="blockvmenuimpair' . ($altok == 1 ? ' blockvmenufirst' : '') . '">' . "\n"; } else { print '<div class="blockvmenupair' . ($altok == 1 ? ' blockvmenufirst' : '') . '">' . "\n"; } } // Place tabulation $tabstring = ''; $tabul = $menu_array[$i]['level'] - 1; if ($tabul > 0) { for ($j = 0; $j < $tabul; $j++) { $tabstring .= ' '; } } // Add mainmenu in GET url. This make to go back on correct menu even when using Back on browser. $url = dol_buildpath($menu_array[$i]['url'], 1); $url = preg_replace('/__LOGIN__/', $user->login, $url); $url = preg_replace('/__USERID__/', $user->id, $url); if (!preg_match('/mainmenu=/i', $menu_array[$i]['url'])) { if (!preg_match('/\\?/', $url)) { $url .= '?'; } else { $url .= '&'; } $url .= 'mainmenu=' . $mainmenu; } print '<!-- Process menu entry with mainmenu=' . $menu_array[$i]['mainmenu'] . ', leftmenu=' . $menu_array[$i]['leftmenu'] . ', level=' . $menu_array[$i]['level'] . ' enabled=' . $menu_array[$i]['enabled'] . ' -->' . "\n"; // Menu niveau 0 if ($menu_array[$i]['level'] == 0) { if ($menu_array[$i]['enabled']) { print '<div class="menu_titre">' . $tabstring . '<a class="vmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>' . $menu_array[$i]['titre'] . '</a></div>'; } else { if ($showmenu) { print '<div class="menu_titre">' . $tabstring . '<font class="vmenudisabled">' . $menu_array[$i]['titre'] . '</font></div>' . "\n"; } } if ($showmenu) { print '<div class="menu_top"></div>' . "\n"; } } // Menu niveau > 0 if ($menu_array[$i]['level'] > 0) { if ($menu_array[$i]['enabled']) { print '<div class="menu_contenu">' . $tabstring; if ($menu_array[$i]['url']) { print '<a class="vsmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; } else { print '<span class="vsmenu">'; } print $menu_array[$i]['titre']; if ($menu_array[$i]['url']) { print '</a>'; } else { print '</span>'; } // If title is not pure text and contains a table, no carriage return added if (!strstr($menu_array[$i]['titre'], '<table')) { print '<br>'; } print '</div>' . "\n"; } else { if ($showmenu) { print '<div class="menu_contenu">' . $tabstring . '<font class="vsmenudisabled vsmenudisabledmargin">' . $menu_array[$i]['titre'] . '</font><br></div>' . "\n"; } } } // If next is a new block or if there is nothing after if (empty($menu_array[$i + 1]['level'])) { if ($showmenu) { print '<div class="menu_end"></div>' . "\n"; } if ($blockvmenuopened) { print "</div>\n"; $blockvmenuopened = false; } } } if ($altok) { print '<div class="blockvmenuend"></div>'; } } if (is_array($moredata) && !empty($moredata['bookmarks'])) { print "\n"; print "<!-- Begin Bookmarks -->\n"; print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">' . "\n"; print $moredata['bookmarks']; print '</div>' . "\n"; print "<!-- End Bookmarks -->\n"; } return count($menu_array); }
/** * Function to build a compiled PDF * * @param DoliDB $db Database handler * @param Translate $langs Object langs * @param Conf $conf Object conf * @param string $diroutputpdf Dir to output file * @param string $newlangid Lang id * @param array $filter Array with filters * @param date $dateafterdate Invoice after date * @param date $datebeforedate Invoice before date * @param date $paymentdateafter Payment after date (must includes hour) * @param date $paymentdatebefore Payment before date (must includes hour) * @param int $usestdout Add information onto standard output * @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template * @param string $filesuffix Suffix to add into file name of generated PDF * @param string $paymentbankid Only if payment on this bank account id * @param array $thirdpartiesid List of thirdparties id when using filter excludethirdpartiesid or onlythirdpartiesid * @param string $fileprefix Prefix to add into filename of generated PDF * @return int Error code */ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate = 0, $filesuffix = '', $paymentbankid = '', $thirdpartiesid = '', $fileprefix = 'mergedpdf') { $sql = "SELECT DISTINCT f.rowid, f.facnumber"; $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f"; $sqlwhere = ''; $sqlorder = ''; if (in_array('all', $filter)) { $sqlorder = " ORDER BY f.facnumber ASC"; } if (in_array('date', $filter)) { if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= " f.fk_statut > 0"; $sqlwhere .= " AND f.datef >= '" . $db->idate($dateafterdate) . "'"; $sqlwhere .= " AND f.datef <= '" . $db->idate($datebeforedate) . "'"; $sqlorder = " ORDER BY f.datef ASC"; } if (in_array('nopayment', $filter)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiement_facture as pf ON f.rowid = pf.fk_facture"; if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= " f.fk_statut > 0"; $sqlwhere .= " AND pf.fk_paiement IS NULL"; } if (in_array('payments', $filter) || in_array('bank', $filter)) { $sql .= ", " . MAIN_DB_PREFIX . "paiement_facture as pf, " . MAIN_DB_PREFIX . "paiement as p"; if (in_array('bank', $filter)) { $sql .= ", " . MAIN_DB_PREFIX . "bank as b"; } if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= " f.fk_statut > 0"; $sqlwhere .= " AND f.rowid = pf.fk_facture"; $sqlwhere .= " AND pf.fk_paiement = p.rowid"; if (in_array('payments', $filter)) { $sqlwhere .= " AND p.datep >= '" . $db->idate($paymentdateafter) . "'"; $sqlwhere .= " AND p.datep <= '" . $db->idate($paymentdatebefore) . "'"; } if (in_array('bank', $filter)) { $sqlwhere .= " AND p.fk_bank = b.rowid"; $sqlwhere .= " AND b.fk_account = " . $paymentbankid; } $sqlorder = " ORDER BY p.datep ASC"; } if (in_array('nodeposit', $filter)) { if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= ' type <> 3'; } if (in_array('noreplacement', $filter)) { if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= ' type <> 1'; } if (in_array('nocreditnote', $filter)) { if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= ' type <> 2'; } if (in_array('excludethirdparties', $filter) && is_array($thirdpartiesid)) { if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= ' f.fk_soc NOT IN (' . join(',', $thirdpartiesid) . ')'; } if (in_array('onlythirdparties', $filter) && is_array($thirdpartiesid)) { if (empty($sqlwhere)) { $sqlwhere = ' WHERE '; } else { $sqlwhere .= " AND"; } $sqlwhere .= ' f.fk_soc IN (' . join(',', $thirdpartiesid) . ')'; } if ($sqlwhere) { $sql .= $sqlwhere; } if ($sqlorder) { $sql .= $sqlorder; } //print $sql; exit; dol_syslog("scripts/invoices/rebuild_merge.php:", LOG_DEBUG); if ($usestdout) { print '--- start' . "\n"; } // Start of transaction //$db->begin(); $error = 0; $result = 0; $files = array(); // liste les fichiers dol_syslog("scripts/invoices/rebuild_merge.php", LOG_DEBUG); if ($resql = $db->query($sql)) { $num = $db->num_rows($resql); $cpt = 0; $oldemail = ''; $message = ''; $total = ''; if ($num) { // First loop on each resultset to build PDF // ----------------------------------------- while ($cpt < $num) { $obj = $db->fetch_object($resql); $fac = new Facture($db); $result = $fac->fetch($obj->rowid); if ($result > 0) { $outputlangs = $langs; if (!empty($newlangid)) { if ($outputlangs->defaultlang != $newlangid) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlangid); } } $filename = $conf->facture->dir_output . '/' . $fac->ref . '/' . $fac->ref . '.pdf'; if ($regenerate || !dol_is_file($filename)) { if ($usestdout) { print "Build PDF for invoice " . $obj->facnumber . " - Lang = " . $outputlangs->defaultlang . "\n"; } $result = $fac->generateDocument($regenerate ? $regenerate : $fac->modelpdf, $outputlangs); } else { if ($usestdout) { print "PDF for invoice " . $obj->facnumber . " already exists\n"; } } // Add file into files array $files[] = $filename; } if ($result <= 0) { $error++; if ($usestdout) { print "Error: Failed to build PDF for invoice " . ($fac->ref ? $fac->ref : ' id ' . $obj->rowid) . "\n"; } else { dol_syslog("Failed to build PDF for invoice " . ($fac->ref ? $fac->ref : ' id ' . $obj->rowid), LOG_ERR); } } $cpt++; } // Define format of output PDF $formatarray = pdf_getFormat($langs); $page_largeur = $formatarray['width']; $page_hauteur = $formatarray['height']; $format = array($page_largeur, $page_hauteur); if ($usestdout) { print "Using output PDF format " . join('x', $format) . "\n"; } else { dol_syslog("Using output PDF format " . join('x', $format), LOG_ERR); } // Now, build a merged files with all files in $files array //--------------------------------------------------------- // Create empty PDF $pdf = pdf_getInstance($format); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); } $pdf->SetFont(pdf_getPDFFont($langs)); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) { $pdf->SetCompression(false); } //$pdf->SetCompression(false); // Add all others foreach ($files as $file) { if ($usestdout) { print "Merge PDF file for invoice " . $file . "\n"; } else { dol_syslog("Merge PDF file for invoice " . $file); } // Charge un document PDF depuis un fichier. $pagecount = $pdf->setSourceFile($file); for ($i = 1; $i <= $pagecount; $i++) { $tplidx = $pdf->importPage($i); $s = $pdf->getTemplatesize($tplidx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $pdf->useTemplate($tplidx); } } // Create output dir if not exists dol_mkdir($diroutputpdf); // Save merged file $filename = $fileprefix; if (empty($filename)) { $filename = 'mergedpdf'; } if (!empty($filesuffix)) { $filename .= '_' . $filesuffix; } $file = $diroutputpdf . '/' . $filename . '.pdf'; if (!$error && $pagecount) { $pdf->Output($file, 'F'); if (!empty($conf->global->MAIN_UMASK)) { @chmod($file, octdec($conf->global->MAIN_UMASK)); } } if ($usestdout) { if (!$error) { print "Merged PDF has been built in " . $file . "\n"; } else { print "Can't build PDF " . $file . "\n"; } } $result = 1; } else { if ($usestdout) { print "No invoices found for criteria.\n"; } else { dol_syslog("No invoices found for criteria"); } $result = 0; } } else { dol_print_error($db); dol_syslog("scripts/invoices/rebuild_merge.php: Error"); $error++; } if ($error) { return -1; } else { return $result; } }
/** * Return HTML table with list of projects and number of opened tasks * * @param DoliDB $db Database handler * @param Form $form Object form * @param int $socid Id thirdparty * @param int $projectsListId Id of project I have permission on * @param int $mytasks Limited to task I am contact to * @param int $statut -1=No filter on statut, 0 or 1 = Filter on status * @param array $listofoppstatus List of opportunity status * @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', ) * @return void */ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array()) { global $langs, $conf, $user, $bc; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $projectstatic = new Project($db); $thirdpartystatic = new Societe($db); $sortfield = ''; $sortorder = ''; $project_year_filter = 0; $title = $langs->trans("Projects"); if (strcmp($statut, '') && $statut >= 0) { $title = $langs->trans("Projects") . ' ' . $langs->trans($projectstatic->statuts_long[$statut]); } $arrayidtypeofcontact = array(); print '<table class="noborder" width="100%">'; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p"; if ($mytasks) { $sql .= ", " . MAIN_DB_PREFIX . "projet_task as t"; $sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec"; $sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet"; } $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.rowid IN (" . $projectsListId . ")"; if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; } if ($mytasks) { $sql .= " AND p.rowid = t.fk_projet"; $sql .= " AND ec.element_id = t.rowid"; $sql .= " AND ec.fk_socpeople = " . $user->id; $sql .= " AND ec.fk_c_type_contact = ctc.rowid"; // Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact $sql .= " AND ctc.element = 'project_task'"; } if ($statut >= 0) { $sql .= " AND p.fk_statut = " . $statut; } if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { $project_year_filter = GETPOST("project_year_filter"); //Check if empty or invalid year. Wildcard ignores the sql check if ($project_year_filter != "*") { if (empty($project_year_filter) || !ctype_digit($project_year_filter)) { $project_year_filter = date("Y"); } $sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")"; $sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")"; } } // Get id of project we must show tasks $arrayidofprojects = array(); $sql1 = "SELECT p.rowid as projectid"; $sql1 .= $sql; $resql = $db->query($sql1); if ($resql) { $i = 0; $num = $db->num_rows($resql); while ($i < $num) { $objp = $db->fetch_object($resql); $arrayidofprojects[$objp->projectid] = $objp->projectid; $i++; } } else { dol_print_error($db); } if (empty($arrayidofprojects)) { $arrayidofprojects[0] = -1; } // Get list of project with calculation on tasks $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,"; $sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload"; $sql2 .= " FROM " . MAIN_DB_PREFIX . "projet as p"; $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = p.fk_soc"; $sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet"; $sql2 .= " WHERE p.rowid IN (" . join(',', $arrayidofprojects) . ")"; $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount"; $sql2 .= " ORDER BY p.title, p.ref"; $var = true; $resql = $db->query($sql2); if ($resql) { $total_task = 0; $total_opp_amount = 0; $ponderated_opp_amount = 0; $num = $db->num_rows($resql); $i = 0; print '<tr class="liste_titre">'; print_liste_field_titre($title . ' <span class="badge">' . $num . '</span>', $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("ThirdParty"), $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder); if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print_liste_field_titre($langs->trans("OpportunityAmount"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("OpportunityStatus"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder); if (!in_array('plannedworkload', $hiddenfields)) { print_liste_field_titre($langs->trans("PlannedWorkload"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } if (!in_array('declaredprogress', $hiddenfields)) { print_liste_field_titre($langs->trans("ProgressDeclared"), "", "", "", "", 'align="right"', $sortfield, $sortorder); } } print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print "</tr>\n"; while ($i < $num) { $objp = $db->fetch_object($resql); $projectstatic->id = $objp->projectid; $projectstatic->user_author_id = $objp->fk_user_creat; $projectstatic->public = $objp->public; // Check is user has read permission on project $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td>'; $projectstatic->ref = $objp->ref; print $projectstatic->getNomUrl(1); if (!in_array('projectlabel', $hiddenfields)) { print ' - ' . dol_trunc($objp->title, 24); } print '</td>'; print '<td>'; if ($objp->fk_soc > 0) { $thirdpartystatic->id = $objp->fk_soc; $thirdpartystatic->ref = $objp->socname; $thirdpartystatic->name = $objp->socname; print $thirdpartystatic->getNomUrl(1); } print '</td>'; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td align="right">'; if ($objp->opp_amount) { print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency); } print '</td>'; print '<td align="right">'; $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code'); if ($code) { print $langs->trans("OppStatus" . $code); } print '</td>'; } $projectstatic->statut = $objp->status; if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<td align="right">' . $objp->nb . '</td>'; $plannedworkload = $objp->planned_workload; $total_plannedworkload += $plannedworkload; if (!in_array('plannedworkload', $hiddenfields)) { print '<td align="right">' . ($plannedworkload ? convertSecondToTime($plannedworkload) : '') . '</td>'; } if (!in_array('declaredprogress', $hiddenfields)) { $declaredprogressworkload = $objp->declared_progess_workload; $total_declaredprogressworkload += $declaredprogressworkload; print '<td align="right">'; //print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>"; print $plannedworkload ? round(100 * $declaredprogressworkload / $plannedworkload, 0) . '%' : ''; print '</td>'; } } print '<td align="right">' . $projectstatic->getLibStatut(3) . '</td>'; print "</tr>\n"; $total_task = $total_task + $objp->nb; $total_opp_amount = $total_opp_amount + $objp->opp_amount; $ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100); } $i++; } print '<tr class="liste_total">'; print '<td colspan="2">' . $langs->trans("Total") . "</td>"; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td class="liste_total" align="right">' . price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency) . '</td>'; print '<td class="liste_total" align="right">' . $form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1) . '</td>'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { print '<td class="liste_total" align="right">' . $total_task . '</td>'; if (!in_array('plannedworkload', $hiddenfields)) { print '<td class="liste_total" align="right">' . ($total_plannedworkload ? convertSecondToTime($total_plannedworkload) : '') . '</td>'; } if (!in_array('declaredprogress', $hiddenfields)) { print '<td class="liste_total" align="right">' . ($total_plannedworkload ? round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0) . '%' : '') . '</td>'; } } print '<td class="liste_total"></td>'; print '</tr>'; $db->free($resql); } else { dol_print_error($db); } print "</table>"; if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { //Add the year filter input print '<form method="get" action="' . $_SERVER["PHP_SELF"] . '">'; print '<table width="100%">'; print '<tr>'; print '<td>' . $langs->trans("Year") . '</td>'; print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="' . $project_year_filter . '"/>'; print "</tr>\n"; print '</table></form>'; } }
/** * Core function to output left menu eldy * * @param DoliDB $db Database handler * @param array $menu_array_before Table of menu entries to show before entries of menu handler (menu->liste filled with menu->add) * @param array $menu_array_after Table of menu entries to show after entries of menu handler (menu->liste filled with menu->add) * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param Menu $menu Object Menu to return back list of menu entries * @param int $noout Disable output (Initialise &$menu only). * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all) * @return int nb of menu entries */ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '') { global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc; $newmenu = $menu; $mainmenu = $forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"]; $leftmenu = $forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]); // Show logo company if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $mysoc->logo_mini = $conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; if (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_mini)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&modulepart=companylogo&file=' . urlencode('thumbs/' . $mysoc->logo_mini); } else { $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; } $title = $langs->trans("GoIntoSetupToChangeLogo"); print "\n" . '<!-- Show logo on menu -->' . "\n"; print '<div class="blockvmenuimpair">' . "\n"; print '<div class="menu_titre" id="menu_titre_logo"></div>'; print '<div class="menu_top" id="menu_top_logo"></div>'; print '<div class="menu_contenu" id="menu_contenu_logo">'; print '<div class="center"><img title="' . dol_escape_htmltag($title) . '" alt="" src="' . $urllogo . '" style="max-width: 80%"></div>' . "\n"; print '</div>'; print '<div class="menu_end" id="menu_end_logo"></div>'; print '</div>' . "\n"; } /** * We update newmenu with entries found into database * -------------------------------------------------- */ if ($mainmenu) { /* * Menu HOME */ if ($mainmenu == 'home') { $langs->load("users"); //if ($user->admin) //{ // Setup $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup'); if (empty($leftmenu) || $leftmenu == "setup") { $langs->load("admin"); $langs->load("help"); $warnpicto = ''; if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { $langs->load("errors"); $warnpicto = ' ' . img_warning($langs->trans("WarningMandatorySetupNotComplete")); } $newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup") . $warnpicto, 1); $warnpicto = ''; if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { $langs->load("errors"); $warnpicto = ' ' . img_warning($langs->trans("WarningMandatorySetupNotComplete")); } $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules") . $warnpicto, 1); $newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"), 1); $newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"), 1); if (!in_array($langs->defaultlang, array('en_US'))) { $newmenu->add("/admin/translation.php", $langs->trans("Translation"), 1); } $newmenu->add("/admin/boxes.php?mainmenu=home", $langs->trans("Boxes"), 1); $newmenu->add("/admin/delais.php?mainmenu=home", $langs->trans("Alerts"), 1); $newmenu->add("/admin/security_other.php?mainmenu=home", $langs->trans("Security"), 1); $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"), 1); $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"), 1); $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"), 1); $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"), 1); $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("Dictionary"), 1); $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1); } // System tools $newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("SystemTools"), 0, $user->admin, '', $mainmenu, 'admintools'); if (empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) { $langs->load("admin"); $langs->load("help"); $newmenu->add('/admin/system/dolibarr.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('InfoDolibarr'), 1); if (empty($leftmenu) || $leftmenu == 'admintools_info') { $newmenu->add('/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Modules'), 2); } if (empty($leftmenu) || $leftmenu == 'admintools_info') { $newmenu->add('/admin/triggers.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Triggers'), 2); } //if (empty($leftmenu) || $leftmenu=='admintools_info') $newmenu->add('/admin/system/filecheck.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('FileCheck'), 2); $newmenu->add('/admin/system/browser.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoBrowser'), 1); $newmenu->add('/admin/system/os.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoOS'), 1); $newmenu->add('/admin/system/web.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoWebServer'), 1); $newmenu->add('/admin/system/phpinfo.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoPHP'), 1); //if (function_exists('xdebug_is_enabled')) $newmenu->add('/admin/system/xdebug.php', $langs->trans('XDebug'),1); $newmenu->add('/admin/system/database.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoDatabase'), 1); if (function_exists('eaccelerator_info')) { $newmenu->add("/admin/tools/eaccelerator.php?mainmenu=home&leftmenu=admintools", $langs->trans("EAccelerator"), 1); } //$newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoPerf"),1); $newmenu->add("/admin/tools/purge.php?mainmenu=home&leftmenu=admintools", $langs->trans("Purge"), 1); $newmenu->add("/admin/tools/dolibarr_export.php?mainmenu=home&leftmenu=admintools", $langs->trans("Backup"), 1); $newmenu->add("/admin/tools/dolibarr_import.php?mainmenu=home&leftmenu=admintools", $langs->trans("Restore"), 1); $newmenu->add("/admin/tools/update.php?mainmenu=home&leftmenu=admintools", $langs->trans("MenuUpgrade"), 1); $newmenu->add("/admin/tools/listevents.php?mainmenu=home&leftmenu=admintools", $langs->trans("Audit"), 1); $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1); $newmenu->add('/admin/system/about.php?mainmenu=home&leftmenu=admintools', $langs->trans('About'), 1); $newmenu->add("/support/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("HelpCenter"), 1, 1, 'targethelp'); } // Modules system tools if (!empty($conf->product->enabled) || !empty($conf->service->enabled) || !empty($conf->barcode->enabled) || !empty($conf->global->MAIN_MENU_ENABLE_MODULETOOLS)) { if (empty($user->societe_id)) { $newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ModulesSystemTools"), 0, $user->admin, '', $mainmenu, 'modulesadmintools'); // Special case: This entry can't be embedded into modules because we need it for both module service and products and we don't want duplicate lines. if ((empty($leftmenu) || $leftmenu == "modulesadmintools") && $user->admin) { $langs->load("products"); $newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin); } } } //} $newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->rights->user->user->lire, '', $mainmenu, 'users'); if ($user->rights->user->user->lire) { if (empty($leftmenu) || $leftmenu == 'none' || $leftmenu == "users") { $newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/card.php?action=create", $langs->trans("NewUser"), 2, $user->rights->user->user->creer || $user->admin, '', 'home'); $newmenu->add("/user/index.php", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/hierarchy.php", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("", $langs->trans("Groups"), 1, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/group/card.php?action=create", $langs->trans("NewGroup"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->write : $user->rights->user->user->creer) || $user->admin); $newmenu->add("/user/group/index.php", $langs->trans("ListOfGroups"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->read : $user->rights->user->user->lire) || $user->admin); } } } /* * Menu THIRDPARTIES */ if ($mainmenu == 'companies') { // Societes if (!empty($conf->societe->enabled)) { $langs->load("companies"); $newmenu->add("/societe/index.php?leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->rights->societe->lire, '', $mainmenu, 'thirdparties'); if ($user->rights->societe->creer) { $newmenu->add("/societe/soc.php?action=create", $langs->trans("MenuNewThirdParty"), 1); if (!$conf->use_javascript_ajax) { $newmenu->add("/societe/soc.php?action=create&private=1", $langs->trans("MenuNewPrivateIndividual"), 1); } } } $newmenu->add("/societe/list.php?leftmenu=thirdparties", $langs->trans("List"), 1); // Prospects if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { $langs->load("commercial"); $newmenu->add("/comm/prospect/list.php?leftmenu=prospects", $langs->trans("ListProspectsShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'prospects'); /* no more required, there is a filter that can do more if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=-1", $langs->trans("LastProspectDoNotContact"), 2, $user->rights->societe->lire); if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=0", $langs->trans("LastProspectNeverContacted"), 2, $user->rights->societe->lire); if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=1", $langs->trans("LastProspectToContact"), 2, $user->rights->societe->lire); if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=2", $langs->trans("LastProspectContactInProcess"), 2, $user->rights->societe->lire); if (empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/comm/prospect/list.php?sortfield=s.datec&sortorder=desc&begin=&search_stcomm=3", $langs->trans("LastProspectContactDone"), 2, $user->rights->societe->lire); */ $newmenu->add("/societe/soc.php?leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer); //$newmenu->add("/contact/list.php?leftmenu=customers&type=p", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire); } // Customers/Prospects if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $langs->load("commercial"); $newmenu->add("/comm/list.php?leftmenu=customers", $langs->trans("ListCustomersShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'customers'); $newmenu->add("/societe/soc.php?leftmenu=customers&action=create&type=c", $langs->trans("MenuNewCustomer"), 2, $user->rights->societe->creer); //$newmenu->add("/contact/list.php?leftmenu=customers&type=c", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire); } // Suppliers if (!empty($conf->societe->enabled) && !empty($conf->fournisseur->enabled)) { $langs->load("suppliers"); $newmenu->add("/fourn/list.php?leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers'); $newmenu->add("/societe/soc.php?leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire); //$newmenu->add("/fourn/list.php?leftmenu=suppliers", $langs->trans("List"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire); //$newmenu->add("/contact/list.php?leftmenu=suppliers&type=f",$langs->trans("Contacts"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire && $user->rights->societe->contact->lire); } // Contacts $newmenu->add("/societe/index.php?leftmenu=thirdparties", !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ThirdParty") : $langs->trans("ContactsAddresses"), 0, $user->rights->societe->contact->lire, '', $mainmenu, 'contacts'); $newmenu->add("/contact/card.php?leftmenu=contacts&action=create", !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"), 1, $user->rights->societe->contact->creer); $newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire); if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire); } if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire); } if (!empty($conf->fournisseur->enabled)) { $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire); } $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("Others"), 2, $user->rights->societe->contact->lire); //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->rights->societe->contact->lire); // Categories if (!empty($conf->categorie->enabled)) { $langs->load("categories"); if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { // Categories prospects/customers $newmenu->add("/categories/index.php?leftmenu=cat&type=2", $langs->trans("CustomersProspectsCategoriesShort"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); $newmenu->add("/categories/card.php?action=create&type=2", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); } // Categories Contact $newmenu->add("/categories/index.php?leftmenu=cat&type=4", $langs->trans("ContactCategoriesShort"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); $newmenu->add("/categories/card.php?action=create&type=4", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); // Categories suppliers if (!empty($conf->fournisseur->enabled)) { $newmenu->add("/categories/index.php?leftmenu=cat&type=1", $langs->trans("SuppliersCategoriesShort"), 0, $user->rights->categorie->lire); $newmenu->add("/categories/card.php?action=create&type=1", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); } //if (empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); } } /* * Menu COMMERCIAL */ if ($mainmenu == 'commercial') { $langs->load("companies"); // Propal if (!empty($conf->propal->enabled)) { $langs->load("propal"); $newmenu->add("/comm/propal/index.php?leftmenu=propals", $langs->trans("Prop"), 0, $user->rights->propale->lire, '', $mainmenu, 'propals'); $newmenu->add("/comm/propal.php?action=create&leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer); $newmenu->add("/comm/propal/list.php?leftmenu=propals", $langs->trans("List"), 1, $user->rights->propale->lire); if (empty($leftmenu) || $leftmenu == "propals") { $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=0", $langs->trans("PropalsDraft"), 2, $user->rights->propale->lire); } if (empty($leftmenu) || $leftmenu == "propals") { $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=1", $langs->trans("PropalsOpened"), 2, $user->rights->propale->lire); } if (empty($leftmenu) || $leftmenu == "propals") { $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=2", $langs->trans("PropalStatusSigned"), 2, $user->rights->propale->lire); } if (empty($leftmenu) || $leftmenu == "propals") { $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=3", $langs->trans("PropalStatusNotSigned"), 2, $user->rights->propale->lire); } if (empty($leftmenu) || $leftmenu == "propals") { $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=4", $langs->trans("PropalStatusBilled"), 2, $user->rights->propale->lire); } //if (empty($leftmenu) || $leftmenu=="propals") $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=2,3,4", $langs->trans("PropalStatusClosedShort"), 2, $user->rights->propale->lire); $newmenu->add("/comm/propal/stats/index.php?leftmenu=propals", $langs->trans("Statistics"), 1, $user->rights->propale->lire); } // Customers orders if (!empty($conf->commande->enabled)) { $langs->load("orders"); $newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); $newmenu->add("/commande/card.php?action=create&leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer); $newmenu->add("/commande/list.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire); if (empty($leftmenu) || $leftmenu == "orders") { $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders") { $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders" && !empty($conf->expedition->enabled)) { $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderSentShort"), 2, $user->rights->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders") { $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=3", $langs->trans("StatusOrderToBill"), 2, $user->rights->commande->lire); } // The translation key is StatusOrderToBill but it means StatusDelivered. TODO We should renamed this later if (empty($leftmenu) || $leftmenu == "orders") { $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=4", $langs->trans("StatusOrderProcessed"), 2, $user->rights->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders") { $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire); } $newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->rights->commande->lire); } // Suppliers orders if (!empty($conf->fournisseur->enabled)) { $langs->load("orders"); $newmenu->add("/fourn/commande/index.php?leftmenu=orders_suppliers", $langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers'); $newmenu->add("/fourn/commande/card.php?action=create&leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer); $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire); if (empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire); } if ((empty($leftmenu) || $leftmenu == "orders_suppliers") && empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->fournisseur->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire); } if (empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire); } $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); } // Contrat if (!empty($conf->contrat->enabled)) { $langs->load("contracts"); $newmenu->add("/contrat/index.php?leftmenu=contracts", $langs->trans("Contracts"), 0, $user->rights->contrat->lire, '', $mainmenu, 'contracts'); $newmenu->add("/contrat/card.php?action=create&leftmenu=contracts", $langs->trans("NewContract"), 1, $user->rights->contrat->creer); $newmenu->add("/contrat/list.php?leftmenu=contracts", $langs->trans("List"), 1, $user->rights->contrat->lire); $newmenu->add("/contrat/services.php?leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->rights->contrat->lire); if (empty($leftmenu) || $leftmenu == "contracts") { $newmenu->add("/contrat/services.php?leftmenu=contracts&mode=0", $langs->trans("MenuInactiveServices"), 2, $user->rights->contrat->lire); } if (empty($leftmenu) || $leftmenu == "contracts") { $newmenu->add("/contrat/services.php?leftmenu=contracts&mode=4", $langs->trans("MenuRunningServices"), 2, $user->rights->contrat->lire); } if (empty($leftmenu) || $leftmenu == "contracts") { $newmenu->add("/contrat/services.php?leftmenu=contracts&mode=4&filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->rights->contrat->lire); } if (empty($leftmenu) || $leftmenu == "contracts") { $newmenu->add("/contrat/services.php?leftmenu=contracts&mode=5", $langs->trans("MenuClosedServices"), 2, $user->rights->contrat->lire); } } // Interventions if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 200); $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201); $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202); } } /* * Menu COMPTA-FINANCIAL */ if ($mainmenu == 'accountancy') { $langs->load("companies"); // Customers invoices if (!empty($conf->facture->enabled)) { $langs->load("bills"); $newmenu->add("/compta/facture/list.php", $langs->trans("BillsCustomers"), 0, $user->rights->facture->lire, '', $mainmenu, 'customers_bills'); $newmenu->add("/compta/facture.php?action=create", $langs->trans("NewBill"), 1, $user->rights->facture->creer); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", $langs->trans("List"), 1, $user->rights->facture->lire); if (empty($leftmenu) || $leftmenu == 'customers_bills') { $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills&search_status=3", $langs->trans("BillShortStatusCanceled"), 2, $user->rights->facture->lire); } $newmenu->add("/compta/facture/fiche-rec.php", $langs->trans("ListOfTemplates"), 1, $user->rights->facture->lire); $newmenu->add("/compta/paiement/list.php", $langs->trans("Payments"), 1, $user->rights->facture->lire); if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { $newmenu->add("/compta/paiement/avalider.php", $langs->trans("MenuToValid"), 2, $user->rights->facture->lire); } $newmenu->add("/compta/paiement/rapport.php", $langs->trans("Reportings"), 2, $user->rights->facture->lire); $newmenu->add("/compta/facture/stats/index.php", $langs->trans("Statistics"), 1, $user->rights->facture->lire); $newmenu->add("/compta/facture/mergepdftool.php", $langs->trans("MergingPDFTool"), 1, $user->rights->facture->lire); } // Suppliers if (!empty($conf->societe->enabled) && !empty($conf->fournisseur->enabled)) { $langs->load("bills"); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); $newmenu->add("/fourn/facture/card.php?action=create", $langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); if (empty($leftmenu) || $leftmenu == 'suppliers_bills') { $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); } $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire); $newmenu->add("/compta/facture/stats/index.php?leftmenu=suppliers_bills&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->facture->lire); } // Orders if (!empty($conf->commande->enabled)) { $langs->load("orders"); if (!empty($conf->facture->enabled)) { $newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-3", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); } // if (empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); } // Supplier Orders if (!empty($conf->fournisseur->enabled)) { if (!empty($conf->global->SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE)) { $langs->load("supplier"); $newmenu->add("/fourn/commande/list.php?leftmenu=orders&search_status=5", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); // if (empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); } } // Donations if (!empty($conf->don->enabled)) { $langs->load("donations"); $newmenu->add("/don/index.php?leftmenu=donations&mainmenu=accountancy", $langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations'); if (empty($leftmenu) || $leftmenu == "donations") { $newmenu->add("/don/card.php?action=create", $langs->trans("NewDonation"), 1, $user->rights->don->creer); } if (empty($leftmenu) || $leftmenu == "donations") { $newmenu->add("/don/list.php", $langs->trans("List"), 1, $user->rights->don->lire); } // if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->rights->don->lire); } // Taxes and social contributions if (!empty($conf->tax->enabled) || !empty($conf->salaries->enabled) || !empty($conf->loan->enabled)) { global $mysoc; $permtoshowmenu = !empty($conf->tax->enabled) && $user->rights->tax->charges->lire || !empty($conf->salaries->enabled) && $user->rights->salaries->read || !empty($conf->loan->enabled) && $user->rights->loan->read; $newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy", $langs->trans("MenuSpecialExpenses"), 0, $permtoshowmenu, '', $mainmenu, 'tax'); // Salaries if (!empty($conf->salaries->enabled)) { $langs->load("salaries"); $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=accountancy", $langs->trans("Salaries"), 1, $user->rights->salaries->read, '', $mainmenu, 'tax_salary'); if (empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) { $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 2, $user->rights->salaries->write); } if (empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) { $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary", $langs->trans("Payments"), 2, $user->rights->salaries->read); } } // Loan if (!empty($conf->loan->enabled)) { $langs->load("loan"); $newmenu->add("/loan/index.php?leftmenu=tax_loan&mainmenu=accountancy", $langs->trans("Loans"), 1, $user->rights->loan->read, '', $mainmenu, 'tax_loan'); if (empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) { $newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 2, $user->rights->loan->write); } if (empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) { $newmenu->add("/loan/index.php?leftmenu=tax_loan", $langs->trans("Payments"), 2, $user->rights->loan->read); } if (empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) { $newmenu->add("/loan/calc.php?leftmenu=tax_loan", $langs->trans("Calculator"), 2, $user->rights->loan->calc); } } // Social contributions if (!empty($conf->tax->enabled)) { $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->rights->tax->charges->lire); if (empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) { $newmenu->add("/compta/sociales/charges.php?leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer); } if (empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) { $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social", $langs->trans("List"), 2, $user->rights->tax->charges->lire); } if (empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) { $newmenu->add("/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); } // VAT if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) { $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat&mainmenu=accountancy", $langs->trans("VAT"), 1, $user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat'); if (empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) { $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("NewPayment"), 2, $user->rights->tax->charges->creer); } if (empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) { $newmenu->add("/compta/tva/reglement.php?leftmenu=tax_vat", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); } if (empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) { $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); } if (empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) { $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); } global $mysoc; //Local Taxes //Local Taxes 1 if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) { $newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&mainmenu=accountancy&localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->rights->tax->charges->lire); if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/card.php?leftmenu=tax_vat&action=create&localTaxType=1", $langs->trans("NewPayment"), 2, $user->rights->tax->charges->creer); } if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/reglement.php?leftmenu=tax_vat&localTaxType=1", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); } if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_vat&localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); } if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_vat&localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); } } //Local Taxes 2 if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1")) { $newmenu->add("/compta/localtax/index.php?leftmenu=tax_vat&mainmenu=accountancy&localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->rights->tax->charges->lire); if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/card.php?leftmenu=tax_vat&action=create&localTaxType=2", $langs->trans("NewPayment"), 2, $user->rights->tax->charges->creer); } if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/reglement.php?leftmenu=tax_vat&localTaxType=2", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); } if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_vat&localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); } if (empty($leftmenu) || preg_match('/^tax/i', $leftmenu)) { $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_vat&localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); } } } } } // Accounting Expert if (!empty($conf->accounting->enabled)) { $langs->load("accountancy"); $newmenu->add("/accountancy/customer/index.php?leftmenu=ventil_customer", $langs->trans("CustomersVentilation"), 0, $user->rights->accounting->ventilation->read, '', $mainmenu, 'ventil_customer'); if (empty($leftmenu) || $leftmenu == "ventil_customer") { $newmenu->add("/accountancy/customer/list.php", $langs->trans("ToDispatch"), 1, $user->rights->accounting->ventilation->dispatch); } if (empty($leftmenu) || $leftmenu == "ventil_customer") { $newmenu->add("/accountancy/customer/lines.php", $langs->trans("Dispatched"), 1, $user->rights->accounting->ventilation->read); } if (!empty($conf->fournisseur->enabled)) { $newmenu->add("/accountancy/supplier/index.php?leftmenu=ventil_supplier", $langs->trans("SuppliersVentilation"), 0, $user->rights->accounting->ventilation->read, '', $mainmenu, 'ventil_supplier'); if (empty($leftmenu) || $leftmenu == "ventil_supplier") { $newmenu->add("/accountancy/supplier/list.php", $langs->trans("ToDispatch"), 1, $user->rights->accounting->ventilation->dispatch); } if (empty($leftmenu) || $leftmenu == "ventil_supplier") { $newmenu->add("/accountancy/supplier/lines.php", $langs->trans("Dispatched"), 1, $user->rights->accounting->ventilation->read); } } } // Rapports if (!empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled)) { $langs->load("compta"); // Bilan, resultats $newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("ReportInOut"), 1, $user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire); } if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire); } /* On verra ca avec module compabilite expert if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->rights->compta->resultat->lire); if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->rights->compta->resultat->lire); */ if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/stats/index.php?leftmenu=report", $langs->trans("ReportTurnover"), 1, $user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire); } /* if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->rights->compta->resultat->lire); if (! empty($conf->propal->enabled)) { if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->rights->compta->resultat->lire); if (empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transforme",2,$user->rights->compta->resultat->lire); } */ if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/stats/casoc.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire); } if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report", $langs->trans("ByUsers"), 2, $user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire); } if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"), 2, $user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire); } if (!empty($conf->comptabilite->enabled)) { // Journaux //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); //journaux if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->rights->compta->resultat->lire); } if (empty($leftmenu) || preg_match('/report/', $leftmenu)) { $newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->rights->compta->resultat->lire); } } // Report expert if (!empty($conf->accounting->enabled)) { $langs->load("accountancy"); // Grand livre $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping", $langs->trans("Bookkeeping"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); if (empty($leftmenu) || preg_match('/bookkeeping/', $leftmenu)) { $newmenu->add("/accountancy/bookkeeping/listbyyear.php", $langs->trans("ByYear"), 1, $user->rights->accounting->mouvements->lire); } if (empty($leftmenu) || preg_match('/bookkeeping/', $leftmenu)) { $newmenu->add("/accountancy/bookkeeping/balancebymonth.php", $langs->trans("AccountBalanceByMonth"), 1, $user->rights->accounting->mouvements->lire); } // Accountancy journals if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') { $newmenu->add('/accountancy/journal/index.php?leftmenu=journal', $langs->trans("Journaux"), 0, $user->rights->banque->lire); if ($leftmenu == 'journal') { $sql = "SELECT rowid, label, accountancy_journal"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; $sql .= " WHERE entity = " . $conf->entity; $sql .= " AND clos = 0"; $sql .= " ORDER BY label"; $resql = $db->query($sql); if ($resql) { $numr = $db->num_rows($resql); $i = 0; if ($numr > 0) { while ($i < $numr) { $objp = $db->fetch_object($resql); $newmenu->add('/accountancy/journal/bankjournal.php?id_account=' . $objp->rowid, $langs->trans("Journal") . ' - ' . $objp->label, 1, $user->rights->accounting->comptarapport->lire); $i++; } } } else { dol_print_error($db); } $db->free($resql); // Add other journal $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal", $langs->trans("SellsJournal"), 1, $user->rights->accounting->comptarapport->lire); $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal", $langs->trans("PurchasesJournal"), 1, $user->rights->accounting->comptarapport->lire); } } } } // Setup if (!empty($conf->accounting->enabled)) { $newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy", $langs->trans("Fiscalyear"), 0, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear'); $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy", $langs->trans("Chartofaccounts"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'chartofaccount'); } } /* * Menu BANK */ if ($mainmenu == 'bank') { $langs->load("withdrawals"); $langs->load("banks"); $langs->load("bills"); // Bank-Caisse if (!empty($conf->banque->enabled)) { $newmenu->add("/compta/bank/index.php?leftmenu=bank&mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank'); $newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer); $newmenu->add("/compta/bank/categ.php", $langs->trans("Rubriques"), 1, $user->rights->banque->configurer); $newmenu->add("/compta/bank/search.php", $langs->trans("ListTransactions"), 1, $user->rights->banque->lire); $newmenu->add("/compta/bank/budget.php", $langs->trans("ListTransactionsByCategory"), 1, $user->rights->banque->lire); $newmenu->add("/compta/bank/virement.php", $langs->trans("BankTransfers"), 1, $user->rights->banque->transfer); } // Prelevements if (!empty($conf->prelevement->enabled)) { $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("StandingOrders"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw'); //if (empty($leftmenu) || $leftmenu=="withdraw") $newmenu->add("/compta/prelevement/demandes.php?status=0&mainmenu=bank",$langs->trans("StandingOrderToProcess"),1,$user->rights->prelevement->bons->lire); if (empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/create.php?mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->rights->prelevement->bons->creer); } if (empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/bons.php?mainmenu=bank", $langs->trans("WithdrawalsReceipts"), 1, $user->rights->prelevement->bons->lire); } if (empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/list.php?mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->rights->prelevement->bons->lire); } if (empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->prelevement->bons->lire); } if (empty($leftmenu) || $leftmenu == "withdraw") { $newmenu->add("/compta/prelevement/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->prelevement->bons->lire); } //if (empty($leftmenu) || $leftmenu=="withdraw") $newmenu->add("/compta/prelevement/config.php",$langs->trans("Setup"),1,$user->rights->prelevement->bons->configurer); } // Gestion cheques if (!empty($conf->banque->enabled) && !empty($conf->facture->enabled) || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON)) { $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks'); $newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks&action=new&mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque); $newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->cheque); } } /* * Menu PRODUCTS-SERVICES */ if ($mainmenu == 'products') { // Products if (!empty($conf->product->enabled)) { $newmenu->add("/product/index.php?leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product'); $newmenu->add("/product/card.php?leftmenu=product&action=create&type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer); $newmenu->add("/product/list.php?leftmenu=product&type=0", $langs->trans("List"), 1, $user->rights->produit->lire); if (!empty($conf->stock->enabled)) { $newmenu->add("/product/reassort.php?type=0", $langs->trans("Stocks"), 1, $user->rights->produit->lire && $user->rights->stock->lire); } if (!empty($conf->productbatch->enabled)) { $langs->load("stocks"); $newmenu->add("/product/reassortlot.php?type=0", $langs->trans("StocksByLotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire); } if (!empty($conf->propal->enabled)) { $newmenu->add("/product/popuprop.php?leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire); } } // Services if (!empty($conf->service->enabled)) { $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service'); $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer); $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire); if (!empty($conf->propal->enabled)) { $newmenu->add("/product/popuprop.php?leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire); } } // Categories if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=0", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); $newmenu->add("/categories/card.php?action=create&type=0", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); //if (empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); } // Warehouse if (!empty($conf->stock->enabled)) { $langs->load("stocks"); $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); $newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->rights->stock->creer); $newmenu->add("/product/stock/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); $newmenu->add("/product/stock/mouvement.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire); if ($conf->fournisseur->enabled) { $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire); } $newmenu->add("/product/stock/massstockmove.php", $langs->trans("StockTransfer"), 1, $user->rights->stock->mouvement->creer); } // Expeditions if (!empty($conf->expedition->enabled)) { $langs->load("sendings"); $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings'); $newmenu->add("/expedition/card.php?action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->rights->expedition->creer); $newmenu->add("/expedition/list.php?leftmenu=sendings", $langs->trans("List"), 1, $user->rights->expedition->lire); if (empty($leftmenu) || $leftmenu == "sendings") { $newmenu->add("/expedition/list.php?leftmenu=sendings&viewstatut=0", $langs->trans("StatusSendingDraftShort"), 2, $user->rights->expedition->lire); } if (empty($leftmenu) || $leftmenu == "sendings") { $newmenu->add("/expedition/list.php?leftmenu=sendings&viewstatut=1", $langs->trans("StatusSendingValidatedShort"), 2, $user->rights->expedition->lire); } if (empty($leftmenu) || $leftmenu == "sendings") { $newmenu->add("/expedition/list.php?leftmenu=sendings&viewstatut=2", $langs->trans("StatusSendingProcessedShort"), 2, $user->rights->expedition->lire); } $newmenu->add("/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1, $user->rights->expedition->lire); } } /* * Menu SUPPLIERS */ /* if ($mainmenu == 'suppliers') { $langs->load("suppliers"); if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled)) { $newmenu->add("/fourn/index.php?leftmenu=suppliers", $langs->trans("Suppliers"), 0, $user->rights->societe->lire && $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers'); // Security check $newmenu->add("/societe/soc.php?leftmenu=suppliers&action=create&type=f",$langs->trans("NewSupplier"), 1, $user->rights->societe->creer && $user->rights->fournisseur->lire); $newmenu->add("/fourn/list.php",$langs->trans("List"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire); $newmenu->add("/contact/list.php?leftmenu=suppliers&type=f",$langs->trans("Contacts"), 1, $user->rights->societe->contact->lire && $user->rights->fournisseur->lire); $newmenu->add("/fourn/stats.php",$langs->trans("Statistics"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire); } if (! empty($conf->facture->enabled)) { $langs->load("bills"); $newmenu->add("/fourn/facture/list.php?leftmenu=orders", $langs->trans("Bills"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'orders'); $newmenu->add("/fourn/facture/card.php?action=create",$langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer); $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire); } if (! empty($conf->fournisseur->enabled)) { $langs->load("orders"); $newmenu->add("/fourn/commande/index.php?leftmenu=suppliers",$langs->trans("Orders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'suppliers'); $newmenu->add("/societe/societe.php?leftmenu=supplier", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer); $newmenu->add("/fourn/commande/list.php?leftmenu=suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire); } if (! empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=1", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); $newmenu->add("/categories/card.php?action=create&type=1", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); //if (empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); } } */ /* * Menu PROJECTS */ if ($mainmenu == 'project') { if (!empty($conf->projet->enabled)) { $langs->load("projects"); // Project affected to user $newmenu->add("/projet/index.php?leftmenu=projects&mode=mine", $langs->trans("MyProjects"), 0, $user->rights->projet->lire, '', $mainmenu, 'myprojects'); $newmenu->add("/projet/card.php?leftmenu=projects&action=create&mode=mine", $langs->trans("NewProject"), 1, $user->rights->projet->creer); $newmenu->add("/projet/list.php?leftmenu=projects&mode=mine&search_status=1", $langs->trans("List"), 1, $user->rights->projet->lire); // All project i have permission on $newmenu->add("/projet/index.php?leftmenu=projects", $langs->trans("Projects"), 0, $user->rights->projet->lire && $user->rights->projet->lire, '', $mainmenu, 'projects'); $newmenu->add("/projet/card.php?leftmenu=projects&action=create", $langs->trans("NewProject"), 1, $user->rights->projet->creer && $user->rights->projet->creer); $newmenu->add("/projet/list.php?leftmenu=projects&search_status=1", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire); $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire && $user->rights->projet->lire); if (empty($conf->global->PROJECT_HIDE_TASKS)) { // Project affected to user $newmenu->add("/projet/activity/index.php?mode=mine", $langs->trans("MyActivities"), 0, $user->rights->projet->lire); $newmenu->add("/projet/tasks.php?action=create&mode=mine", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add("/projet/tasks/index.php?mode=mine", $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add("/projet/activity/perweek.php?mode=mine", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer); // All project i have permission on $newmenu->add("/projet/activity/index.php", $langs->trans("Activities"), 0, $user->rights->projet->lire && $user->rights->projet->lire); $newmenu->add("/projet/tasks.php?action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer && $user->rights->projet->creer); $newmenu->add("/projet/tasks/index.php", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire); $newmenu->add("/projet/activity/perweek.php", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer && $user->rights->projet->creer); } } } /* * Menu HRM */ if ($mainmenu == 'hrm') { // Leave/Holiday/Vacation module if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $langs->load("trips"); $newmenu->add("/holiday/list.php?&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm'); $newmenu->add("/holiday/card.php?&action=request", $langs->trans("New"), 1, $user->rights->holiday->write); $newmenu->add("/holiday/list.php?&leftmenu=hrm", $langs->trans("List"), 1, $user->rights->holiday->read); $newmenu->add("/holiday/list.php?select_statut=2&leftmenu=hrm", $langs->trans("ListToApprove"), 2, $user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->define_holiday); $newmenu->add("/holiday/view_log.php?&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); $newmenu->add("/holiday/month_report.php?&action=request", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->define_holiday); } // Trips and expenses (old module) if (!empty($conf->deplacement->enabled)) { $langs->load("trips"); $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses'); $newmenu->add("/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->deplacement->creer); $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->deplacement->lire); $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire); } } /* * Menu TOOLS */ if ($mainmenu == 'tools') { if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $langs->trans("EMailings"), 0, $user->rights->mailing->lire, '', $mainmenu, 'mailing'); $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&action=create", $langs->trans("NewMailing"), 1, $user->rights->mailing->creer); $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire); } if (!empty($conf->export->enabled)) { $langs->load("exports"); $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->rights->export->lire, '', $mainmenu, 'export'); $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->rights->export->creer); //$newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->rights->export->lire); } if (!empty($conf->import->enabled)) { $langs->load("exports"); $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans("FormatedImport"), 0, $user->rights->import->run, '', $mainmenu, 'import'); $newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->rights->import->run); } } /* * Menu MEMBERS */ if ($mainmenu == 'members') { if (!empty($conf->adherent->enabled)) { $langs->load("members"); $langs->load("compta"); $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Members"), 0, $user->rights->adherent->lire, '', $mainmenu, 'members'); $newmenu->add("/adherents/card.php?leftmenu=members&action=create", $langs->trans("NewMember"), 1, $user->rights->adherent->creer); $newmenu->add("/adherents/list.php?leftmenu=members", $langs->trans("List"), 1, $user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1", $langs->trans("MenuMembersToValidate"), 2, $user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=1", $langs->trans("MenuMembersValidated"), 2, $user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=uptodate", $langs->trans("MenuMembersUpToDate"), 2, $user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=outofdate", $langs->trans("MenuMembersNotUpToDate"), 2, $user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=0", $langs->trans("MenuMembersResiliated"), 2, $user->rights->adherent->lire); $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire); $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members", $langs->trans("Subscriptions"), 0, $user->rights->adherent->cotisation->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1,1&mainmenu=members", $langs->trans("NewSubscription"), 1, $user->rights->adherent->cotisation->creer); $newmenu->add("/adherents/cotisations.php?leftmenu=members", $langs->trans("List"), 1, $user->rights->adherent->cotisation->lire); $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire); if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=3", $langs->trans("Categories"), 0, $user->rights->categorie->lire, '', $mainmenu, 'cat'); $newmenu->add("/categories/card.php?action=create&type=3", $langs->trans("NewCategory"), 1, $user->rights->categorie->creer); //if (empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); } $newmenu->add("/adherents/index.php?leftmenu=export&mainmenu=members", $langs->trans("Exports"), 0, $user->rights->adherent->export, '', $mainmenu, 'export'); if (!empty($conf->export->enabled) && (empty($leftmenu) || $leftmenu == "export")) { $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("Datas"), 1, $user->rights->adherent->export); } if (empty($leftmenu) || $leftmenu == "export") { $newmenu->add("/adherents/htpasswd.php?leftmenu=export", $langs->trans("Filehtpasswd"), 1, $user->rights->adherent->export); } if (empty($leftmenu) || $leftmenu == "export") { $newmenu->add("/adherents/cartes/carte.php?leftmenu=export", $langs->trans("MembersCards"), 1, $user->rights->adherent->export); } // Type $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("MembersTypes"), 0, $user->rights->adherent->configurer, '', $mainmenu, 'setup'); $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members&action=create", $langs->trans("New"), 1, $user->rights->adherent->configurer); $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("List"), 1, $user->rights->adherent->configurer); } } // Add personalized menus and modules menus $menuArbo = new Menubase($db, 'eldy'); $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, empty($user->societe_id) ? 0 : 1, 'eldy', $tabMenu); // We update newmenu for special dynamic menus if (!empty($user->rights->banque->lire) && $mainmenu == 'bank') { $sql = "SELECT rowid, label, courant, rappro"; $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; $sql .= " WHERE entity = " . $conf->entity; $sql .= " AND clos = 0"; $sql .= " ORDER BY label"; $resql = $db->query($sql); if ($resql) { $numr = $db->num_rows($resql); $i = 0; if ($numr > 0) { $newmenu->add('/compta/bank/index.php', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire); } while ($i < $numr) { $objp = $db->fetch_object($resql); $newmenu->add('/compta/bank/card.php?id=' . $objp->rowid, $objp->label, 1, $user->rights->banque->lire); if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) { $newmenu->add('/compta/bank/rappro.php?account=' . $objp->rowid, $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate); } $i++; } } else { dol_print_error($db); } $db->free($resql); } if (!empty($conf->ftp->enabled) && $mainmenu == 'ftp') { $MAXFTP = 20; $i = 1; while ($i <= $MAXFTP) { $paramkey = 'FTP_NAME_' . $i; //print $paramkey; if (!empty($conf->global->{$paramkey})) { $link = "/ftp/index.php?idmenu=" . $_SESSION["idmenu"] . "&numero_ftp=" . $i; $newmenu->add($link, dol_trunc($conf->global->{$paramkey}, 24)); } $i++; } } } // Build final $menu_array = $menu_array_before +$newmenu->liste + $menu_array_after //var_dump($menu_array_before);exit; //var_dump($menu_array_after);exit; $menu_array = $newmenu->liste; if (is_array($menu_array_before)) { $menu_array = array_merge($menu_array_before, $menu_array); } if (is_array($menu_array_after)) { $menu_array = array_merge($menu_array, $menu_array_after); } //var_dump($menu_array);exit; if (!is_array($menu_array)) { return 0; } // Show menu $invert = empty($conf->global->MAIN_MENU_INVERT) ? "" : "invert"; if (empty($noout)) { $alt = 0; $blockvmenuopened = false; $num = count($menu_array); for ($i = 0; $i < $num; $i++) { $showmenu = true; if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) { $showmenu = false; } $alt++; if (empty($menu_array[$i]['level']) && $showmenu) { $blockvmenuopened = true; if ($alt % 2 == 0) { print '<div class="blockvmenuimpair' . $invert . '">' . "\n"; } else { print '<div class="blockvmenupair' . $invert . '">' . "\n"; } } // Place tabulation $tabstring = ''; $tabul = $menu_array[$i]['level'] - 1; if ($tabul > 0) { for ($j = 0; $j < $tabul; $j++) { $tabstring .= ' '; } } // For external modules $tmp = explode('?', $menu_array[$i]['url'], 2); $url = $tmp[0]; $param = isset($tmp[1]) ? $tmp[1] : ''; $url = dol_buildpath($url, 1) . ($param ? '?' . $param : ''); $url = preg_replace('/__LOGIN__/', $user->login, $url); $url = preg_replace('/__USERID__/', $user->id, $url); print '<!-- Process menu entry with mainmenu=' . $menu_array[$i]['mainmenu'] . ', leftmenu=' . $menu_array[$i]['leftmenu'] . ', level=' . $menu_array[$i]['level'] . ' enabled=' . $menu_array[$i]['enabled'] . ' -->' . "\n"; // Menu niveau 0 if ($menu_array[$i]['level'] == 0) { if ($menu_array[$i]['enabled']) { print '<div class="menu_titre">' . $tabstring . '<a class="vmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>' . $menu_array[$i]['titre'] . '</a></div>' . "\n"; } else { if ($showmenu) { print '<div class="menu_titre">' . $tabstring . '<font class="vmenudisabled">' . $menu_array[$i]['titre'] . '</font></div>' . "\n"; } } if ($showmenu) { print '<div class="menu_top"></div>' . "\n"; } } // Menu niveau > 0 if ($menu_array[$i]['level'] > 0) { if ($menu_array[$i]['enabled']) { print '<div class="menu_contenu">' . $tabstring; if ($menu_array[$i]['url']) { print '<a class="vsmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; } else { print '<span class="vsmenu">'; } print $menu_array[$i]['titre']; if ($menu_array[$i]['url']) { print '</a>'; } else { print '</span>'; } // If title is not pure text and contains a table, no carriage return added if (!strstr($menu_array[$i]['titre'], '<table')) { print '<br>'; } print '</div>' . "\n"; } else { if ($showmenu) { print '<div class="menu_contenu">' . $tabstring . '<font class="vsmenudisabled vsmenudisabledmargin">' . $menu_array[$i]['titre'] . '</font><br></div>' . "\n"; } } } // If next is a new block or if there is nothing after if (empty($menu_array[$i + 1]['level'])) { if ($showmenu) { print '<div class="menu_end"></div>' . "\n"; } if ($blockvmenuopened) { print "</div>\n"; $blockvmenuopened = false; } } } } return count($menu_array); }
/** * Renvoi si un code est pris ou non (par autre tiers) * * @param DoliDB $db Handler acces base * @param string $code Code a verifier * @param Societe $soc Objet societe * @return int 0 if available, <0 if KO */ function verif_dispo($db, $code, $soc) { global $conf, $mc; $sql = "SELECT code_client FROM " . MAIN_DB_PREFIX . "societe"; $sql .= " WHERE code_client = '" . $code . "'"; $sql .= " AND entity IN (" . getEntity('societe', 1) . ")"; if ($soc->id > 0) { $sql .= " AND rowid <> " . $soc->id; } dol_syslog(get_class($this) . "::verif_dispo", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { return 0; } else { return -1; } } else { return -2; } }
/** * Return HTML table with list of projects and number of opened tasks * * @param DoliDB $db Database handler * @param int $socid Id thirdparty * @param int $projectsListId Id of project i have permission on * @param int $mytasks Limited to task i am contact to * @param int $statut -1=No filter on statut, 0 or 1 = Filter on status * @return void */ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks = 0, $statut = -1) { global $langs, $conf, $user, $bc; require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $projectstatic = new Project($db); $sortfield = ''; $sortorder = ''; $project_year_filter = 0; $title = $langs->trans("Project"); if ($statut == 0) { $title = $langs->trans("ProjectDraft"); } if ($statut == 1) { $title = $langs->trans("Project") . ' (' . $langs->trans("Validated") . ')'; } print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print_liste_field_titre($title, "index.php", "", "", "", "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder); print "</tr>\n"; $sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, COUNT(t.rowid) as nb"; $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p"; if ($mytasks) { $sql .= ", " . MAIN_DB_PREFIX . "projet_task as t"; $sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec"; $sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet"; } $sql .= " WHERE p.entity = " . $conf->entity; $sql .= " AND p.rowid IN (" . $projectsListId . ")"; if ($socid) { $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")"; } if ($mytasks) { $sql .= " AND p.rowid = t.fk_projet"; $sql .= " AND ec.element_id = t.rowid"; $sql .= " AND ctc.rowid = ec.fk_c_type_contact"; $sql .= " AND ctc.element = 'project_task'"; $sql .= " AND ec.fk_socpeople = " . $user->id; } if ($statut >= 0) { $sql .= " AND p.fk_statut = " . $statut; } if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { $project_year_filter = GETPOST("project_year_filter"); //Check if empty or invalid year. Wildcard ignores the sql check if ($project_year_filter != "*") { if (empty($project_year_filter) || !ctype_digit($project_year_filter)) { // $project_year_filter = date("Y"); } $sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")"; $sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")"; } } $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut"; $sql .= " ORDER BY p.title, p.ref"; $var = true; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $projectstatic->id = $objp->projectid; $projectstatic->user_author_id = $objp->fk_user_creat; $projectstatic->public = $objp->public; // Check is user has read permission on project $userAccess = $projectstatic->restrictedProjectArea($user); if ($userAccess >= 0) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td class="nowrap">'; $projectstatic->ref = $objp->ref; print $projectstatic->getNomUrl(1); print ' - ' . dol_trunc($objp->title, 24) . '</td>'; print '<td align="right">' . $objp->nb . '</td>'; $projectstatic->statut = $objp->fk_statut; print '<td align="right">' . $projectstatic->getLibStatut(3) . '</td>'; print "</tr>\n"; } $i++; } $db->free($resql); } else { dol_print_error($db); } print "</table>"; if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) { //Add the year filter input print '<table width="100%">'; print '<tr>'; print '<td>' . $langs->trans("Year") . '</td>'; print '<form method="get" action="' . $_SERVER["PHP_SELF"] . '">'; print '<td style="text-align:right"><input type="text" size="4" class="flat" name="project_year_filter" value="' . $project_year_filter . '"/>'; print '</form>'; print "</tr>\n"; print '</table>'; } }